From a42ec2035f7e41a01b3cc0f6bf45c57fb6c9cd39 Mon Sep 17 00:00:00 2001 From: tuexen Date: Mon, 22 Jun 2015 05:31:29 +0000 Subject: MFC r284547: 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 --- usr.bin/sockstat/sockstat.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'usr.bin/sockstat') 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(); -- cgit v1.1