public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Mike Saal <msaal@qacafe•com>
To: netdev@vger•kernel.org
Subject: ss format bug
Date: Wed, 26 Aug 2015 11:59:17 -0400	[thread overview]
Message-ID: <55DDE255.1010003@qacafe.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 573 bytes --]

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

[-- Attachment #2: ss.patch --]
[-- Type: text/x-patch, Size: 464 bytes --]

diff -Nuar iproute2-4.1.1.orig/misc/ss.c iproute2-4.1.1/misc/ss.c
--- iproute2-4.1.1.orig/misc/ss.c	2015-07-06 17:57:34.000000000 -0400
+++ iproute2-4.1.1/misc/ss.c	2015-08-20 10:37:17.615100588 -0400
@@ -1023,6 +1023,8 @@
 	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),



             reply	other threads:[~2015-08-26 15:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-26 15:59 Mike Saal [this message]
2015-08-31 23:23 ` ss format bug Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55DDE255.1010003@qacafe.com \
    --to=msaal@qacafe$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox