aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dyndhcpd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/dyndhcpd.c b/dyndhcpd.c
index bee300a..a9283a0 100644
--- a/dyndhcpd.c
+++ b/dyndhcpd.c
@@ -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++;