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:
Joe Marcus Clarke 2008-12-19 06:50:15 +00:00
parent 6c3b8117ad
commit 08afefa814
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=186315
2 changed files with 4 additions and 0 deletions

View File

@ -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];

View File

@ -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);