diff options
author | tuexen <tuexen@FreeBSD.org> | 2015-06-18 13:45:07 +0000 |
---|---|---|
committer | tuexen <tuexen@FreeBSD.org> | 2015-06-18 13:45:07 +0000 |
commit | fc90da544630962c4a564d4c73ab3d4c6e9df40e (patch) | |
tree | 7bf60b4e507024e488984073060545515d2249d5 /usr.bin | |
parent | 59940b0c9512717b13fb3a7c9916018b319d38b8 (diff) | |
download | FreeBSD-src-fc90da544630962c4a564d4c73ab3d4c6e9df40e.zip FreeBSD-src-fc90da544630962c4a564d4c73ab3d4c6e9df40e.tar.gz |
Fix a bug reported by coverity. Since AF_UNIX sockets don't
have multiple addresses, the problem didn't show up during testing.
Reported by: Coverity
CID: 1306787
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sockstat/sockstat.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c index a1edd34..1299f97 100644 --- a/usr.bin/sockstat/sockstat.c +++ b/usr.bin/sockstat/sockstat.c @@ -865,6 +865,7 @@ displaysock(struct sock *s, int pos) void *p; int hash; struct addr *laddr, *faddr; + struct sock *s_tmp; while (pos < 29) pos += xprintf(" "); @@ -908,18 +909,20 @@ displaysock(struct sock *s, int pos) } pos += xprintf("-> "); for (hash = 0; hash < HASHSIZE; ++hash) { - for (s = sockhash[hash]; s != NULL; s = s->next) - if (s->pcb == p) + for (s_tmp = sockhash[hash]; + s_tmp != NULL; + s_tmp = s_tmp->next) + if (s_tmp->pcb == p) break; - if (s != NULL) + if (s_tmp != NULL) break; } - if (s == NULL || - s->laddr == NULL || - s->laddr->address.ss_len == 0) + if (s_tmp == NULL || + s_tmp->laddr == NULL || + s_tmp->laddr->address.ss_len == 0) pos += xprintf("??"); else - pos += printaddr(&s->laddr->address); + pos += printaddr(&s_tmp->laddr->address); break; default: abort(); |