From: ume Date: Thu, 5 Nov 2015 11:02:28 +0000 (+0000) Subject: Use returned network name from getnetbyaddr() correctly. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e649998b7f9113ecf9cf69627d17c953fc94655b;p=people%2Fliuw%2Ffreebsd.git Use returned network name from getnetbyaddr() correctly. --- diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 2ab35a0ffd7..3f6918cc160 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -637,14 +637,13 @@ netname4(in_addr_t in, in_addr_t mask) trimdomain(cp, strlen(cp)); } } - inet_ntop(AF_INET, &in, nline, sizeof(line)); - if (cp != NULL) { - if (strcpy(cp, nline) != 0) - return (line); + if (cp != NULL) strlcpy(line, cp, sizeof(line)); - } else + else { + inet_ntop(AF_INET, &in, nline, sizeof(nline)); strlcpy(line, nline, sizeof(line)); - domask(line + strlen(line), i, ntohl(mask)); + domask(line + strlen(line), i, ntohl(mask)); + } return (line); }