Do not segfault when procstat -f or procstat -v is called on a process not
owned by the current user. If kinfo_getfile() or kinfo_getvmmap() return NULL, simply exit, and do not try and derefernce the memory. Reviewed by: peter Approved by: peter
This commit is contained in:
parent
2368f18ac4
commit
0abe5b951a
@ -144,6 +144,8 @@ procstat_files(pid_t pid, struct kinfo_proc *kipp)
|
||||
"PRO", "NAME");
|
||||
|
||||
freep = kinfo_getfile(pid, &cnt);
|
||||
if (freep == NULL)
|
||||
return;
|
||||
for (i = 0; i < cnt; i++) {
|
||||
kif = &freep[i];
|
||||
|
||||
|
@ -54,6 +54,8 @@ procstat_vm(pid_t pid, struct kinfo_proc *kipp __unused)
|
||||
"PRES", "REF", "SHD", "FL", "TP", "PATH");
|
||||
|
||||
freep = kinfo_getvmmap(pid, &cnt);
|
||||
if (freep == NULL)
|
||||
return;
|
||||
for (i = 0; i < cnt; i++) {
|
||||
kve = &freep[i];
|
||||
printf("%5d ", pid);
|
||||
|
Loading…
Reference in New Issue
Block a user