diff options
author | marcus <marcus@FreeBSD.org> | 2008-12-19 06:50:15 +0000 |
---|---|---|
committer | marcus <marcus@FreeBSD.org> | 2008-12-19 06:50:15 +0000 |
commit | 0abe5b951a7aaf746e27a5f530787ec38ea88fac (patch) | |
tree | 3bf1db210e6cd2863aba11fbfa3c4420e85a0395 | |
parent | 2368f18ac465224da2b90e0037f39d141448e123 (diff) | |
download | FreeBSD-src-0abe5b951a7aaf746e27a5f530787ec38ea88fac.zip FreeBSD-src-0abe5b951a7aaf746e27a5f530787ec38ea88fac.tar.gz |
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
-rw-r--r-- | usr.bin/procstat/procstat_files.c | 2 | ||||
-rw-r--r-- | usr.bin/procstat/procstat_vm.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/usr.bin/procstat/procstat_files.c b/usr.bin/procstat/procstat_files.c index 1f620f3..74ec590 100644 --- a/usr.bin/procstat/procstat_files.c +++ b/usr.bin/procstat/procstat_files.c @@ -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]; diff --git a/usr.bin/procstat/procstat_vm.c b/usr.bin/procstat/procstat_vm.c index 79c0e57..1873c4f 100644 --- a/usr.bin/procstat/procstat_vm.c +++ b/usr.bin/procstat/procstat_vm.c @@ -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); |