FreeBSD Bugzilla – Attachment 159030 Details for
Bug 201700
netstat -s segmentation fault after pfkey section
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
patch
netstat_counters.diff (text/plain), 1.40 KB, created by
Mark Johnston
on 2015-07-20 22:23:25 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Mark Johnston
Created:
2015-07-20 22:23:25 UTC
Size:
1.40 KB
patch
obsolete
>commit 6388d2ea1251e88ce844a60a802fa3e4527655e1 >Author: Mark Johnston <markjdb@gmail.com> >Date: Mon Jul 20 14:58:16 2015 -0700 > > netstat(1): fix counter reads on 32-bit platforms > > kread_counters() assumed that sizeof(counter_u64_t) (aka uint64_t *) and > sizeof(uint64_t) are equal, but this isn't always true. The problem was > only visible with IPSEC counters however, since all other counters are > currently read using sysctls rather than going through libkvm. > >diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c >index acc27f7..477add6 100644 >--- a/usr.bin/netstat/main.c >+++ b/usr.bin/netstat/main.c >@@ -776,19 +776,31 @@ kread_counter(u_long addr) > int > kread_counters(u_long addr, void *buf, size_t size) > { >- uint64_t *c = buf; >+ uint64_t *c; >+ u_long *counters; >+ size_t i, n; > > if (kvmd_init() < 0) > return (-1); > >- if (kread(addr, buf, size) < 0) >+ if (size % sizeof(uint64_t) != 0) { >+ xo_warnx("kread_counters: invalid counter set size"); > return (-1); >+ } > >- while (size != 0) { >- *c = kvm_counter_u64_fetch(kvmd, *c); >- size -= sizeof(*c); >- c++; >+ n = size / sizeof(uint64_t); >+ if ((counters = malloc(n * sizeof(u_long))) == NULL) >+ xo_err(-1, "malloc"); >+ if (kread(addr, counters, n * sizeof(u_long)) < 0) { >+ free(counters); >+ return (-1); > } >+ >+ c = buf; >+ for (i = 0; i < n; i++) >+ c[i] = kvm_counter_u64_fetch(kvmd, counters[i]); >+ >+ free(counters); > return (0); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 201700
:
158989
|
158990
| 159030