Bug#628005: netstat and program title

Mats Andersson debian at gisladisker.se
Wed Sep 21 00:43:12 UTC 2011


Remember that NUL is the word separator in process command lines.
(Apply "hexdump -C /proc/23456/cmdline".)

Netstat is conceived to print the command name, not the title,
thus displaying a single string of __printable__ characters.
Technical disection if the source code will reveal a call to
strrchr() inside netstat.c/prg_cache_load(), which will
stop looking further than the first NUL character, and
which in fact appear soon enough.

Something like the difference reproduced below, would indeed
produce what the bug reporter desires, but I see very little
reason to commend such a change. It discloses too much info
for the general process.


--- netstat.c.debian
+++ netstat.c
@@ -405,6 +405,7 @@ static void prg_cache_load(void)
                 continue;
 
 	    if (!cmdlp) {
+		int j;
 		if (procfdlen - PATH_FD_SUFFl + PATH_CMDLINEl >= 
 		    sizeof(line) - 5) 
 		    continue;
@@ -419,6 +420,9 @@ static void prg_cache_load(void)
 		    continue;
 		if (cmdllen < sizeof(cmdlbuf) - 1) 
 		    cmdlbuf[cmdllen]='\0';
+		for (j = 0; j < cmdllen; ++j)
+		    if (cmdlbuf[j] == '\0')
+			cmdlbuf[j] = ' ';
 		if ((cmdlp = strrchr(cmdlbuf, '/'))) 
 		    cmdlp++;
 		else 





More information about the Pkg-net-tools-maintainers mailing list