diff options
author | Christian Hesse <mail@eworm.de> | 2016-09-30 09:21:50 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2016-09-30 09:21:50 +0200 |
commit | 14ad87900ea7a286a2b1319f8a19df6b3736d42e (patch) | |
tree | a349b39cffbd6c60c6663f38166b883176170ff6 | |
parent | 4b19f5d7fa199439db85b4f8144fcde34da5617d (diff) | |
download | dyndhcpd-14ad87900ea7a286a2b1319f8a19df6b3736d42e.tar.gz dyndhcpd-14ad87900ea7a286a2b1319f8a19df6b3736d42e.tar.zst |
add error handling for hostname
-rw-r--r-- | dyndhcpd.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -107,8 +107,13 @@ int main(int argc, char ** argv) { goto out; } + /* get the hostname */ + if (gethostname(hostname, HOST_NAME_MAX) == -1) { + fprintf(stderr, "Failed to get the hostname.\n"); + goto out; + } + /* get the domainname */ - gethostname(hostname, HOST_NAME_MAX); hp = gethostbyname(hostname); if ((domainname = strchr(hp->h_name, '.')) != NULL) domainname++; |