From 2eefc17894718cf963b02b0d690e2991e10515c8 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 10 Jun 2016 18:54:10 -0500 Subject: xreadlink() only exits for memory allocation, it returns 0 if file not found. (I forget who reported this bug, wasn't me.) --- toys/pending/netstat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toys') diff --git a/toys/pending/netstat.c b/toys/pending/netstat.c index 02ab4fc2..f8d622e2 100644 --- a/toys/pending/netstat.c +++ b/toys/pending/netstat.c @@ -424,8 +424,8 @@ static void scan_pid_inodes(char *path) if (!isdigit(entry->d_name[0])) continue; snprintf(link_name, sizeof(link_name), "%s/%s", path, entry->d_name); - link = xreadlink(link_name); - if ((inode = ss_inode(link)) != -1) add2list(inode); + if ((link = xreadlink(link_name) && (inode = ss_inode(link))!=-1) + add2list(inode); free(link); } closedir(dp); -- cgit v1.2.3