Date: Fri, 19 Dec 2008 20:23:41 +0000 (UTC) From: Joe Marcus Clarke <marcus@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r186340 - releng/7.1/usr.bin/procstat Message-ID: <200812192023.mBJKNfcM082012@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marcus (doc,ports committer) Date: Fri Dec 19 20:23:38 2008 New Revision: 186340 URL: http://svn.freebsd.org/changeset/base/186340 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: releng/7.1/usr.bin/procstat/procstat_files.c releng/7.1/usr.bin/procstat/procstat_vm.c Modified: releng/7.1/usr.bin/procstat/procstat_files.c ============================================================================== --- releng/7.1/usr.bin/procstat/procstat_files.c Fri Dec 19 20:22:55 2008 (r186339) +++ releng/7.1/usr.bin/procstat/procstat_files.c Fri Dec 19 20:23:38 2008 (r186340) @@ -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: releng/7.1/usr.bin/procstat/procstat_vm.c ============================================================================== --- releng/7.1/usr.bin/procstat/procstat_vm.c Fri Dec 19 20:22:55 2008 (r186339) +++ releng/7.1/usr.bin/procstat/procstat_vm.c Fri Dec 19 20:23:38 2008 (r186340) @@ -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?200812192023.mBJKNfcM082012>