Page MenuHomeFreeBSD

D52275.diff
No OneTemporary

D52275.diff

diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c
--- a/lib/libprocstat/libprocstat.c
+++ b/lib/libprocstat/libprocstat.c
@@ -1973,6 +1973,7 @@
struct ucred ucred;
gid_t *groups;
size_t len;
+ unsigned int ngroups;
assert(kd != NULL);
assert(kp != NULL);
@@ -1990,19 +1991,22 @@
proc.p_ucred, kp->ki_pid);
return (NULL);
}
- len = ucred.cr_ngroups * sizeof(gid_t);
+ ngroups = 1 + ucred.cr_ngroups;
+ len = ngroups * sizeof(gid_t);
groups = malloc(len);
if (groups == NULL) {
warn("malloc(%zu)", len);
return (NULL);
}
- if (!kvm_read_all(kd, (unsigned long)ucred.cr_groups, groups, len)) {
+ groups[0] = ucred.cr_gid;
+ if (!kvm_read_all(kd, (unsigned long)ucred.cr_groups, groups + 1,
+ len - sizeof(gid_t))) {
warnx("can't read groups at %p for pid %d",
ucred.cr_groups, kp->ki_pid);
free(groups);
return (NULL);
}
- *cntp = ucred.cr_ngroups;
+ *cntp = ngroups;
return (groups);
}

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 20, 5:03 PM (3 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31824119
Default Alt Text
D52275.diff (973 B)

Event Timeline