summaryrefslogtreecommitdiffstats
path: root/if-options.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-01-26 09:11:38 +0000
committerRoy Marples <roy@marples.name>2009-01-26 09:11:38 +0000
commit4fb0c27c39d95db8fd8d4da3a3fb552d79f20613 (patch)
treede03534c9bf2d2e9e97779eb3f92eb3afaf634a0 /if-options.c
parentc735a7323a86d426d529573598ccce3859484cbf (diff)
downloaddhcpcd-4fb0c27c39d95db8fd8d4da3a3fb552d79f20613.tar.xz
Ensure that we have enough buffer for gethostname and terminate it correctly.
Diffstat (limited to 'if-options.c')
-rw-r--r--if-options.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/if-options.c b/if-options.c
index 4e8ddbfe..e8eb5186 100644
--- a/if-options.c
+++ b/if-options.c
@@ -676,7 +676,9 @@ read_config(const char *file, const char *ifname, const char *ssid)
ifo->timeout = DEFAULT_TIMEOUT;
ifo->reboot = DEFAULT_REBOOT;
ifo->metric = -1;
- gethostname(ifo->hostname + 1, sizeof(ifo->hostname));
+ gethostname(ifo->hostname + 1, HOSTNAME_MAX_LEN);
+ /* Ensure that the hostname is NULL terminated */
+ ifo->hostname[HOSTNAME_MAX_LEN + 1] = '\0';
if (strcmp(ifo->hostname + 1, "(none)") == 0 ||
strcmp(ifo->hostname + 1, "localhost") == 0)
ifo->hostname[1] = '\0';