From owner-svn-src-all@FreeBSD.ORG Fri Dec 19 20:20:50 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 9D5A31065674; Fri, 19 Dec 2008 20:20:50 +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 8BDC68FC20; Fri, 19 Dec 2008 20:20:50 +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 mBJKKo0g081839; Fri, 19 Dec 2008 20:20:50 GMT (envelope-from marcus@svn.freebsd.org) Received: (from marcus@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBJKKo6P081837; Fri, 19 Dec 2008 20:20:50 GMT (envelope-from marcus@svn.freebsd.org) Message-Id: <200812192020.mBJKKo6P081837@svn.freebsd.org> From: Joe Marcus Clarke Date: Fri, 19 Dec 2008 20:20:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186338 - stable/7/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 20:20:50 -0000 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);