diff options
| author | Roy Marples <roy@marples.name> | 2009-01-26 09:14:54 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2009-01-26 09:14:54 +0000 |
| commit | d5a1ddc98e056a4dc33ef238f8075aaf511a83b0 (patch) | |
| tree | 850843c1fb61cdc0595f57d3601486eb7f9aa3bc | |
| parent | f81197e964ed773c2c940e5efc895a61ac803ab3 (diff) | |
| download | dhcpcd-4.0.8.tar.xz | |
Ensure that we have enough buffer for gethostname and terminate it correctly.dhcpcd-4.0.8
| -rw-r--r-- | dhcpcd.c | 4 | ||||
| -rw-r--r-- | dhcpcd.h | 10 |
2 files changed, 8 insertions, 6 deletions
@@ -648,7 +648,9 @@ main(int argc, char **argv) } #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'; @@ -82,12 +82,12 @@ struct options { 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; |
