]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ss format bug
authorMike Saal <msaal@qacafe.com>
Wed, 26 Aug 2015 15:59:17 +0000 (11:59 -0400)
committerStephen Hemminger <shemming@brocade.com>
Wed, 9 Sep 2015 15:17:42 +0000 (08:17 -0700)
Hi:

I found a formatting bug in the 4.1.1 ss command. The following line was
incorrectly output due to passing a negative length to printf() when
displaying the local address. In this instance hostapd does a "bind to
device" on cdreth0 and then does a udp "in address any" port 67 bind.
Please note the whitespace between the '*' and ' %cdreth0:67'

    'udp UNCONN 0 0 ** %cdreth0:67* *:* users:(("hostapd",pid=19241,fd=5))'

Attached is my patch for the bug fix, it might be prudent to add more
guard code looking for negative length format codes.

Sincerely, Mike

misc/ss.c

index 2f34962284785ea1360e55281ac550298ad19396..9efc3c8508dfc90d89be7018ea60c6afd18ee709 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1020,6 +1020,8 @@ static void inet_addr_print(const inet_prefix *a, int port, unsigned int ifindex
        if (ifindex) {
                ifname   = ll_index_to_name(ifindex);
                est_len -= strlen(ifname) + 1;  /* +1 for percent char */
+               if (est_len < 0)
+                       est_len = 0;
        }
 
        sock_addr_print_width(est_len, ap, ":", serv_width, resolve_service(port),