summaryrefslogtreecommitdiff
path: root/usr.bin/sockstat
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@FreeBSD.org>2015-06-18 13:45:07 +0000
committerMichael Tuexen <tuexen@FreeBSD.org>2015-06-18 13:45:07 +0000
commit81091202832605c601768abfce1f6744da3c295b (patch)
tree7bf60b4e507024e488984073060545515d2249d5 /usr.bin/sockstat
parent872b4ed5eacc6442bef408c6b637ae0dbf104e8d (diff)
downloadsrc-test-81091202832605c601768abfce1f6744da3c295b.tar.gz
src-test-81091202832605c601768abfce1f6744da3c295b.zip
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
Notes
Notes: svn path=/head/; revision=284547
Diffstat (limited to 'usr.bin/sockstat')
-rw-r--r--usr.bin/sockstat/sockstat.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
index a1edd34cf14b7..1299f9700da94 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();