aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/dhcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/pending/dhcp.c')
-rw-r--r--toys/pending/dhcp.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/toys/pending/dhcp.c b/toys/pending/dhcp.c
index c7ed1bfb..f8226db6 100644
--- a/toys/pending/dhcp.c
+++ b/toys/pending/dhcp.c
@@ -1230,16 +1230,14 @@ static void renew(void)
// Sends a IP release request.
static void release(void)
{
- int len = sizeof("255.255.255.255\0");
- char buffer[len];
+ char buffer[sizeof("255.255.255.255\0")];
struct in_addr temp_addr;
mode_app();
// send release packet
if (state->status == STATE_BOUND || state->status == STATE_RENEWING || state->status == STATE_REBINDING) {
temp_addr.s_addr = htonl(server);
- strncpy(buffer, inet_ntoa(temp_addr), sizeof(buffer));
- buffer[len - 1] = '\0';
+ xstrncpy(buffer, inet_ntoa(temp_addr), sizeof(buffer));
temp_addr.s_addr = state->ipaddr.s_addr;
infomsg( infomode, "Unicasting a release of %s to %s", inet_ntoa(temp_addr), buffer);
dhcpc_sendmsg(DHCPRELEASE);