summaryrefslogtreecommitdiffstats
path: root/usr.bin/sockstat
diff options
context:
space:
mode:
authortuexen <tuexen@FreeBSD.org>2015-06-22 05:31:29 +0000
committertuexen <tuexen@FreeBSD.org>2015-06-22 05:31:29 +0000
commita42ec2035f7e41a01b3cc0f6bf45c57fb6c9cd39 (patch)
tree387fe05cdd21807370bd575b746d453231dbd4e5 /usr.bin/sockstat
parentb6383a0fc85ee750673878ed40d3b962aa11e56e (diff)
downloadFreeBSD-src-a42ec2035f7e41a01b3cc0f6bf45c57fb6c9cd39.zip
FreeBSD-src-a42ec2035f7e41a01b3cc0f6bf45c57fb6c9cd39.tar.gz
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
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 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();
OpenPOWER on IntegriCloud