# HG changeset patch # User Roy Marples # Date 1232961294 0 # Node ID 799259f7cc1b92995a4346b5d263917651bf128f # Parent 25967fb816afba50ea6689dc521fa235c2f49700 Ensure that we have enough buffer for gethostname and terminate it correctly. diff -r 25967fb816af -r 799259f7cc1b dhcpcd.c --- a/dhcpcd.c Thu Jan 22 23:54:53 2009 +0000 +++ b/dhcpcd.c Mon Jan 26 09:14:54 2009 +0000 @@ -648,7 +648,9 @@ } #endif - gethostname(options->hostname + 1, sizeof(options->hostname)); + gethostname(options->hostname + 1, HOSTNAME_MAX_LEN); + /* Ensure that the hostname is NULL terminated */ + options->hostname[HOSTNAME_MAX_LEN + 1] = '\0'; if (strcmp(options->hostname + 1, "(none)") == 0 || strcmp(options->hostname + 1, "localhost") == 0) options->hostname[1] = '\0'; diff -r 25967fb816af -r 799259f7cc1b dhcpcd.h --- a/dhcpcd.h Thu Jan 22 23:54:53 2009 +0000 +++ b/dhcpcd.h Mon Jan 26 09:14:54 2009 +0000 @@ -82,12 +82,12 @@ char script[PATH_MAX]; char pidfile[PATH_MAX]; - char hostname[HOSTNAME_MAX_LEN + 1]; + char hostname[HOSTNAME_MAX_LEN + 2]; int fqdn; - uint8_t vendorclassid[VENDORCLASSID_MAX_LEN + 1]; - char clientid[CLIENTID_MAX_LEN + 1]; - uint8_t userclass[USERCLASS_MAX_LEN + 1]; - uint8_t vendor[VENDOR_MAX_LEN + 1]; + uint8_t vendorclassid[VENDORCLASSID_MAX_LEN + 2]; + char clientid[CLIENTID_MAX_LEN + 2]; + uint8_t userclass[USERCLASS_MAX_LEN + 2]; + uint8_t vendor[VENDOR_MAX_LEN + 2]; size_t blacklist_len; in_addr_t *blacklist;