summaryrefslogtreecommitdiff
path: root/llmnrd.c
diff options
context:
space:
mode:
Diffstat (limited to 'llmnrd.c')
-rw-r--r--llmnrd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/llmnrd.c b/llmnrd.c
index 663d524..48e4030 100644
--- a/llmnrd.c
+++ b/llmnrd.c
@@ -29,6 +29,7 @@
#include <unistd.h>
#include <sys/ioctl.h>
+#include <sys/param.h>
#include "compiler.h"
#include "log.h"
@@ -148,12 +149,12 @@ int main(int argc, char **argv)
register_signal(SIGHUP, signal_handler);
if (!hostname) {
- /* TODO: Consider hostname changing at runtime */
- hostname = xmalloc(255);
- if (gethostname(hostname, 255) != 0) {
+ hostname = xzalloc(MAXHOSTNAMELEN);
+ if (gethostname(hostname, MAXHOSTNAMELEN) != 0) {
log_err("Failed to get hostname");
return EXIT_FAILURE;
}
+ hostname[MAXHOSTNAMELEN - 1] = '\0';
}
if (daemonize) {