aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-06-10 18:54:10 -0500
committerRob Landley <rob@landley.net>2016-06-10 18:54:10 -0500
commit2eefc17894718cf963b02b0d690e2991e10515c8 (patch)
tree541961f12dbb51f5388ef3a5ffe2dc984273bb1d
parentd59e6d528fb6358c99f91e4297f1b92a7d1eb707 (diff)
downloadtoybox-2eefc17894718cf963b02b0d690e2991e10515c8.tar.gz
xreadlink() only exits for memory allocation, it returns 0 if file not found.
(I forget who reported this bug, wasn't me.)
-rw-r--r--toys/pending/netstat.c4
1 files changed, 2 insertions, 2 deletions
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);