diff options
author | jmg <jmg@FreeBSD.org> | 2003-11-08 07:24:03 +0000 |
---|---|---|
committer | jmg <jmg@FreeBSD.org> | 2003-11-08 07:24:03 +0000 |
commit | 66e31fa9e34b09080c8333069fb06d02509eb8b5 (patch) | |
tree | 05e34a80fffaa13aca77bbd745527e2246ecdc0f /usr.bin/vmstat | |
parent | 48868cdc766a51214c5872684469fc526360a09a (diff) | |
download | FreeBSD-src-66e31fa9e34b09080c8333069fb06d02509eb8b5.zip FreeBSD-src-66e31fa9e34b09080c8333069fb06d02509eb8b5.tar.gz |
fix an overflow bug when scanning for length of names that I introduced in
the last commit...
include some minor style changes and fixes that bde sent me
Submitted by: bde
Diffstat (limited to 'usr.bin/vmstat')
-rw-r--r-- | usr.bin/vmstat/vmstat.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 730dee9..22444c3 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -143,11 +143,11 @@ kvm_t *kd; static void cpustats(void); static void devstats(void); -static void dosysctl(char *); +static void doforkst(void); static void domem(void); static void dointr(void); static void dosum(void); -static void doforkst(void); +static void dosysctl(char *); static void dovmstat(u_int, int); static void dozmem(void); static void kread(int, void *, size_t); @@ -743,8 +743,9 @@ dointr() errx(1, "malloc"); kread(X_INTRCNT, intrcnt, (size_t)nintr); kread(X_INTRNAMES, intrname, (size_t)inamlen); + nintr /= sizeof(u_long); tintrname = intrname; - istrnamlen = 14; + istrnamlen = 12; for (i = 0; i < nintr; i++) { clen = strlen(tintrname); if (clen > istrnamlen) @@ -754,7 +755,6 @@ dointr() (void)printf("%-*s %20s %10s\n", istrnamlen, "interrupt", "total", "rate"); inttotal = 0; - nintr /= sizeof(long); while (--nintr >= 0) { if (*intrcnt) (void)printf("%-*s %20lu %10lu\n", istrnamlen, intrname, @@ -792,7 +792,7 @@ dosysctl(char *name) if (sysctlbyname(name, buf, &bufsize, 0, NULL) == 0) break; if (errno != ENOMEM) - err(1, "sysctl()"); + err(1, "sysctlbyname()"); bufsize *= 2; } buf[bufsize] = '\0'; /* play it safe */ @@ -817,7 +817,7 @@ kread(nlx, addr, size) ++sym; errx(1, "symbol %s not defined", sym); } - if (kvm_read(kd, namelist[nlx].n_value, addr, size) != (int)size) { + if ((size_t)kvm_read(kd, namelist[nlx].n_value, addr, size) != size) { sym = namelist[nlx].n_name; if (*sym == '_') ++sym; |