From 82effc97f9f2d1c258ea50cb11b130753b8ba805 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 1 Jan 2015 16:59:35 -0600 Subject: Switch a lot of strncpy() calls to xstrncpy(). --- toys/pending/dhcp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'toys/pending/dhcp.c') 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); -- cgit v1.2.3