From owner-svn-src-all@FreeBSD.ORG Fri Dec 19 06:50:16 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 162381065670; Fri, 19 Dec 2008 06:50:16 +0000 (UTC) (envelope-from marcus@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0561E8FC1B; Fri, 19 Dec 2008 06:50:16 +0000 (UTC) (envelope-from marcus@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBJ6oFnt064351; Fri, 19 Dec 2008 06:50:15 GMT (envelope-from marcus@svn.freebsd.org) Received: (from marcus@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBJ6oFxl064349; Fri, 19 Dec 2008 06:50:15 GMT (envelope-from marcus@svn.freebsd.org) Message-Id: <200812190650.mBJ6oFxl064349@svn.freebsd.org> From: Joe Marcus Clarke Date: Fri, 19 Dec 2008 06:50:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186315 - head/usr.bin/procstat X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Dec 2008 06:50:16 -0000 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);