net-tools/net-tools-1.60-netstat-p-basename.patch
2011-06-09 12:07:02 +02:00

27 lines
1006 B
Diff

diff -up net-tools-1.60/netstat.c.p-basename net-tools-1.60/netstat.c
--- net-tools-1.60/netstat.c.p-basename 2011-06-09 12:01:59.907721330 +0200
+++ net-tools-1.60/netstat.c 2011-06-09 12:02:28.437352480 +0200
@@ -413,7 +413,7 @@ static void prg_cache_load(void)
{
char line[LINE_MAX],eacces=0;
int procfdlen,fd,cmdllen,lnamelen;
- char lname[30],cmdlbuf[512],finbuf[PROGNAME_WIDTH];
+ char lname[30],cmdlbuf[512],finbuf[PROGNAME_WIDTH],*cmdlpend;
unsigned long inode;
const char *cs,*cmdlp;
DIR *dirproc=NULL,*dirfd=NULL;
@@ -484,10 +484,12 @@ static void prg_cache_load(void)
continue;
if (cmdllen < sizeof(cmdlbuf) - 1)
cmdlbuf[cmdllen]='\0';
- if ((cmdlp = strrchr(cmdlbuf, '/')))
+ if (cmdlbuf[0] == '/' && (cmdlp = strrchr(cmdlbuf, '/')))
cmdlp++;
else
cmdlp = cmdlbuf;
+ if ((cmdlpend = strrchr(cmdlp, ':')) != NULL)
+ *cmdlpend = '\0';
}
snprintf(finbuf, sizeof(finbuf), "%s/%s", direproc->d_name, cmdlp);