aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-01-01 16:49:55 -0600
committerRob Landley <rob@landley.net>2015-01-01 16:49:55 -0600
commit5f53d130b1eae9041cc88c0ffb89e2b5823da393 (patch)
tree0a1586e4762e9eec9ff2ac74da4f0ea37f543600
parent86c747a4493b2b1aabab9b20d1c4566fddeeb2ca (diff)
downloadtoybox-5f53d130b1eae9041cc88c0ffb89e2b5823da393.tar.gz
strncpy(optptr, hname, strlen(hname)) is really just strcpy().
-rw-r--r--toys/pending/dhcp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/toys/pending/dhcp.c b/toys/pending/dhcp.c
index bdaefcaa..c7ed1bfb 100644
--- a/toys/pending/dhcp.c
+++ b/toys/pending/dhcp.c
@@ -288,7 +288,7 @@ static int get_interface( char *interface, int *ifindex, uint32_t *oip, uint8_t
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 @@ static int mode_app(void)
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 @@ static uint8_t *dhcpc_addreqipaddr(struct in_addr *ipaddr, uint8_t *optptr)
}
// 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;
}