]> xenbits.xensource.com Git - people/liuw/freebsd.git/commitdiff
Use returned network name from getnetbyaddr() correctly.
authorume <ume@FreeBSD.org>
Thu, 5 Nov 2015 11:02:28 +0000 (11:02 +0000)
committerume <ume@FreeBSD.org>
Thu, 5 Nov 2015 11:02:28 +0000 (11:02 +0000)
usr.bin/netstat/route.c

index 2ab35a0ffd7ca87a9431bc4a1d1b9e6484584e53..3f6918cc160a145ee639535be0f6591dfc41889a 100644 (file)
@@ -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);
 }