Bug 24556

Summary: netstat returns invalid program names when the cmdline includes a parm that contains slashes
Product: Mageia Reporter: Dave Hodgins <davidwhodgins>
Component: RPM PackagesAssignee: Thierry Vignaud <thierry.vignaud>
Status: NEW --- QA Contact:
Severity: normal    
Priority: Normal Keywords: PATCH
Version: Cauldron   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard: mga6too
Source RPM: net-tools-2.0-0.20150915git.5.mga7.src.rpm CVE:
Status comment:

Description Dave Hodgins 2019-03-25 11:17:49 CET
Running the command "netstat -pvlA inet,inet6" to obtain a list of open ports
parses the cmdline line of the processes to return the program name. When it
works, an example line from the output is ...
udp        0      0 x3.hodgins.homeip.n:ntp 0.0.0.0:*                           2035/ntpd
This is obtained by netstat by returning the first name after the last slash from
# cat /proc/2035/cmdline
/usr/sbin/ntpd-untp:ntp-g
When the cmdline includes a parm that contains a slash in the pararmeter, the
output is from whatever follows the last slash in the parameter. For example
udp 0 0 224.0.0.251:mdns 0.0.0.0:* 15762/122-high-temp
This was obtained by netstat from ...
# cat /proc/15762/cmdline
/opt/google/chrome/chrome https://www.cbc.ca/news/canada/british-columbia/122-high-temperature-records-broken-in-b-c-this-week-1.5065585?cmp=rs

The simplest solution is to change netstat to use /proc/$pid/comm instead of
parsing the program name from the cmdline.

This has been reported upstream at https://sourceforge.net/p/net-tools/bugs/10/
where I've attached an untested patch.

Please apply the patch to the Mageia 7 version of net-tools, for testing to
confirm it fixes the problem. The fix can then be applied to Mageia 6 if it
does work.

I see this problem regularly in the output from msec of the listening ports,
as it uses the above netstat command to obtain it's data, so can test it easily.
Comment 1 Dave Hodgins 2019-03-25 11:20:10 CET
Patch is available from
https://sourceforge.net/p/net-tools/bugs/_discuss/thread/88613e32/f256/attachment/netstat.c.patch

Whiteboard: (none) => mga6too
Keywords: (none) => PATCH