From owner-cvs-all Sat Apr 6 20:50:47 2002 Delivered-To: cvs-all@freebsd.org Received: from bazooka.trit.org (bazooka.trit.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 511B037B417; Sat, 6 Apr 2002 20:50:42 -0800 (PST) Received: by bazooka.trit.org (Postfix, from userid 1000) id 171DB3E31; Sun, 7 Apr 2002 04:50:42 +0000 (UTC) Received: from bazooka (localhost [127.0.0.1]) by bazooka.trit.org (Postfix) with ESMTP id 15D3B3C12E; Sun, 7 Apr 2002 04:50:42 +0000 (UTC) To: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libkvm kvm_proc.c In-Reply-To: <200204070447.g374lwR75411@freefall.freebsd.org>; from dd@FreeBSD.org on "Sat, 6 Apr 2002 20:47:58 -0800 (PST)" Date: Sun, 07 Apr 2002 04:50:37 +0000 From: Dima Dorfman Message-Id: <20020407045042.171DB3E31@bazooka.trit.org> Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Dima Dorfman wrote: > Log: > Fix (for the second time) kvm_getprocs() for the case where no > processes match the given criteria. Since revision 1.60 of malloc.c, > malloc() and friends return an invalid pointer when given a size of 0. > kvm_getprocs() uses sysctl() with a NULL oldp argument to get an > initial size, but does not check whether it's 0 before passing it to > realloc() (via _kvm_realloc()). Before the aforementioned malloc() > change, this resulted in a minimal allocation made and a valid poitner > returned, but now results in an invalid, but non-NULL, pointer being > returned. When this is passed to sysctl(), the latter returns EFAULT > (as it should). The patch committed is admittedly ugly. If someone knows a cleaner way to achieve the same thing, please speak up. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message