diff options
author | robert <robert@FreeBSD.org> | 2003-02-10 16:58:47 +0000 |
---|---|---|
committer | robert <robert@FreeBSD.org> | 2003-02-10 16:58:47 +0000 |
commit | 1932d78f6cce8e4990f0cfb18def3e391327a72e (patch) | |
tree | d8dd9b64208e41965a084592c3f78c743450fe7d /usr.bin | |
parent | acc76cb549c80c862c102cfcdc5df88c6076fdbb (diff) | |
download | FreeBSD-src-1932d78f6cce8e4990f0cfb18def3e391327a72e.zip FreeBSD-src-1932d78f6cce8e4990f0cfb18def3e391327a72e.tar.gz |
- Determine the size of buffers with sizeof() instead of using
plain magic numbers - one of them was apparently wrong but unharmful.
- Remove empty line.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/netstat/if.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index 1b012ce..7b85ddf 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -233,9 +233,10 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *)) if (kread(ifnetaddr, (char *)&ifnet, sizeof ifnet) || kread((u_long)ifnet.if_name, tname, 16)) return; - tname[15] = '\0'; + tname[sizeof(tname) - 1] = '\0'; ifnetaddr = (u_long)TAILQ_NEXT(&ifnet, if_link); - snprintf(name, 32, "%s%d", tname, ifnet.if_unit); + snprintf(name, sizeof(name), "%s%d", tname, + ifnet.if_unit); if (interface != 0 && (strcmp(name, interface) != 0)) continue; cp = index(name, '\0'); @@ -542,15 +543,15 @@ sidewaysintpr(unsigned interval1, u_long off) if (kread(off, (char *)&ifnet, sizeof ifnet)) break; - if (kread((u_long)ifnet.if_name, tname, 16)) + if (kread((u_long)ifnet.if_name, tname, sizeof(tname))) break; - tname[15] = '\0'; - snprintf(name, 16, "%s%d", tname, ifnet.if_unit); + tname[sizeof(tname) - 1] = '\0'; + snprintf(name, sizeof(name), "%s%d", tname, ifnet.if_unit); if (interface && strcmp(name, interface) == 0) { interesting = ip; interesting_off = off; } - snprintf(ip->ift_name, 16, "(%s)", name);; + snprintf(ip->ift_name, sizeof(ip->ift_name), "(%s)", name);; if ((ipn = malloc(sizeof(struct iftot))) == NULL) { printf("malloc failed\n"); exit(1); @@ -571,7 +572,6 @@ sidewaysintpr(unsigned interval1, u_long off) } memset(sum, 0, sizeof(struct iftot)); - (void)signal(SIGALRM, catchalarm); signalled = NO; (void)alarm(interval1); |