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
6c3b8117ad
commit
08afefa814
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=186315
@ -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