Date: Fri, 19 Dec 2008 20:20:50 +0000 (UTC) From: Joe Marcus Clarke <marcus@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r186338 - stable/7/usr.bin/procstat Message-ID: <200812192020.mBJKKo6P081837@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marcus (doc,ports committer) Date: Fri Dec 19 20:20:50 2008 New Revision: 186338 URL: http://svn.freebsd.org/changeset/base/186338 Log: MFC r186315: 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. Approved by: re (kib) Modified: stable/7/usr.bin/procstat/procstat_files.c stable/7/usr.bin/procstat/procstat_vm.c Modified: stable/7/usr.bin/procstat/procstat_files.c ============================================================================== --- stable/7/usr.bin/procstat/procstat_files.c Fri Dec 19 20:20:14 2008 (r186337) +++ stable/7/usr.bin/procstat/procstat_files.c Fri Dec 19 20:20:50 2008 (r186338) @@ -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: stable/7/usr.bin/procstat/procstat_vm.c ============================================================================== --- stable/7/usr.bin/procstat/procstat_vm.c Fri Dec 19 20:20:14 2008 (r186337) +++ stable/7/usr.bin/procstat/procstat_vm.c Fri Dec 19 20:20:50 2008 (r186338) @@ -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?200812192020.mBJKKo6P081837>