From 14ad87900ea7a286a2b1319f8a19df6b3736d42e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 Sep 2016 09:21:50 +0200 Subject: add error handling for hostname --- dyndhcpd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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++; -- cgit v1.2.3-70-g09d2