From: Denis Vlasenko Date: Mon, 4 Jun 2007 21:03:51 +0000 (-0000) Subject: snprintf(... "%s"...) => safe_strncpy X-Git-Tag: 1_7_0~285 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8c1aaf32978da33a462997b269536f1de47c79c6;p=oweals%2Fbusybox.git snprintf(... "%s"...) => safe_strncpy --- diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index 7fc1dbc26..a0d08246a 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c @@ -316,9 +316,12 @@ const char *format_host(int af, int len, void *addr, char *buf, int buflen) default:; } } - if (len > 0 && (h_ent = gethostbyaddr(addr, len, af)) != NULL) { - snprintf(buf, buflen - 1, "%s", h_ent->h_name); - return buf; + if (len > 0) { + h_ent = gethostbyaddr(addr, len, af); + if (h_ent != NULL) { + safe_strncpy(buf, h_ent->h_name, buflen); + return buf; + } } } #endif