aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Marshall <mark.marshall@omicronenergy.com>2018-03-19 10:45:40 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-03-27 23:28:53 +0200
commit98592db3231caa905e6d54129c621f3e8e9bbaa3 (patch)
treeb8f135f0b8abc6a7932f9a05b68eb0f71682a215
parentb5820d9fd88bb6cb1dfd1a934a3d346336d5cac2 (diff)
downloadbusybox-w32-98592db3231caa905e6d54129c621f3e8e9bbaa3.tar.gz
busybox-w32-98592db3231caa905e6d54129c621f3e8e9bbaa3.tar.bz2
busybox-w32-98592db3231caa905e6d54129c621f3e8e9bbaa3.zip
netstat: produce numeric-ip output for non-resolved names
If we don't ask for numerical output, and the symbolic look-up failed we used to get "(null)", but the numeric output would be better. function old new delta ip_port_str 109 121 +12 Signed-off-by: Mark Marshall <mark.marshall@omicronenergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/netstat.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/networking/netstat.c b/networking/netstat.c
index 33281e333..f6bcd44ba 100644
--- a/networking/netstat.c
+++ b/networking/netstat.c
@@ -397,8 +397,11 @@ static char *ip_port_str(struct sockaddr *addr, int port, const char *proto, int
397 /* Code which used "*" for INADDR_ANY is removed: it's ambiguous 397 /* Code which used "*" for INADDR_ANY is removed: it's ambiguous
398 * in IPv6, while "0.0.0.0" is not. */ 398 * in IPv6, while "0.0.0.0" is not. */
399 399
400 host = numeric ? xmalloc_sockaddr2dotted_noport(addr) 400 host = NULL;
401 : xmalloc_sockaddr2host_noport(addr); 401 if (!numeric)
402 host = xmalloc_sockaddr2host_noport(addr);
403 if (!host)
404 host = xmalloc_sockaddr2dotted_noport(addr);
402 405
403 host_port = xasprintf("%s:%s", host, get_sname(htons(port), proto, numeric)); 406 host_port = xasprintf("%s:%s", host, get_sname(htons(port), proto, numeric));
404 free(host); 407 free(host);