# HG changeset patch # User Rob Landley # Date 1420152595 21600 # Node ID 856b544f8fce98308b36707ea73989bbca3ea01d # Parent 184c98250cc5bd0e57229c7104655d05c23f68e9 strncpy(optptr, hname, strlen(hname)) is really just strcpy(). diff -r 184c98250cc5 -r 856b544f8fce toys/pending/dhcp.c --- a/toys/pending/dhcp.c Thu Jan 01 16:28:51 2015 -0600 +++ b/toys/pending/dhcp.c Thu Jan 01 16:49:55 2015 -0600 @@ -288,7 +288,7 @@ int fd = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); req.ifr_addr.sa_family = AF_INET; - strncpy(req.ifr_name, interface, IFNAMSIZ); + xstrncpy(req.ifr_name, interface, IFNAMSIZ); req.ifr_name[IFNAMSIZ-1] = '\0'; xioctl(fd, SIOCGIFFLAGS, &req); @@ -628,7 +628,7 @@ close(state->sockfd); return -1; } - strncpy(ifr.ifr_name, state->iface, IFNAMSIZ); + xstrncpy(ifr.ifr_name, state->iface, IFNAMSIZ); ifr.ifr_name[IFNAMSIZ -1] = '\0'; setsockopt(state->sockfd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)); @@ -884,14 +884,16 @@ } // adds hostname to dhcp packet. -static uint8_t *dhcpc_addfdnname(uint8_t *optptr, char *hname) +static uint8_t *dhcpc_addfdnname(uint8_t *optptr, char *hname) { int size = strlen(hname); + *optptr++ = DHCP_OPTION_FQDN; *optptr++ = size + 3; *optptr++ = 0x1; //flags optptr += 2; // two blank bytes - strncpy((char*)optptr, hname, size); // name + strcpy((char*)optptr, hname); // name + return optptr + size; }