Date: Fri, 19 Dec 2008 06:50:15 +0000 (UTC) From: Joe Marcus Clarke <marcus@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r186315 - head/usr.bin/procstat Message-ID: <200812190650.mBJ6oFxl064349@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marcus (doc,ports committer) Date: Fri Dec 19 06:50:15 2008 New Revision: 186315 URL: http://svn.freebsd.org/changeset/base/186315 Log: 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 Modified: head/usr.bin/procstat/procstat_files.c head/usr.bin/procstat/procstat_vm.c Modified: head/usr.bin/procstat/procstat_files.c ============================================================================== --- head/usr.bin/procstat/procstat_files.c Fri Dec 19 06:47:59 2008 (r186314) +++ head/usr.bin/procstat/procstat_files.c Fri Dec 19 06:50:15 2008 (r186315) @@ -144,6 +144,8 @@ procstat_files(pid_t pid, struct kinfo_p "PRO", "NAME"); freep = kinfo_getfile(pid, &cnt); + if (freep == NULL) + return; for (i = 0; i < cnt; i++) { kif = &freep[i]; Modified: head/usr.bin/procstat/procstat_vm.c ============================================================================== --- head/usr.bin/procstat/procstat_vm.c Fri Dec 19 06:47:59 2008 (r186314) +++ head/usr.bin/procstat/procstat_vm.c Fri Dec 19 06:50:15 2008 (r186315) @@ -54,6 +54,8 @@ procstat_vm(pid_t pid, struct kinfo_proc "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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812190650.mBJ6oFxl064349>