From owner-freebsd-hackers Sat Mar 17 2: 6:55 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id 6F29B37B718 for ; Sat, 17 Mar 2001 02:06:52 -0800 (PST) (envelope-from dwmalone@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 17 Mar 2001 10:06:51 +0000 (GMT) Date: Sat, 17 Mar 2001 10:06:51 +0000 From: David Malone To: Dima Dorfman Cc: hackers@freebsd.org Subject: Re: sysctl_kern_proc doesn't handle the case when no procs match given criteria Message-ID: <20010317100651.A24995@walton.maths.tcd.ie> References: <20010317042351.C1B283E23@bazooka.unixfreak.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010317042351.C1B283E23@bazooka.unixfreak.org>; from dima@unixfreak.org on Fri, Mar 16, 2001 at 08:23:51PM -0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Fri, Mar 16, 2001 at 08:23:51PM -0800, Dima Dorfman wrote: > Obviously, this isn't the desired mode of failure. Attached is a > patch that will make sysctl_kern_proc return ESRCH if it didn't find > any processes. AFAIK, without the patch, the only way to detect this > condition (no processes match search criteria) is to check that a call > into this routine via sysctl didn't modify whatever is pointed at by > the oldp pointer (see sysctl(3)). I went for a much simpler patch that just skipped the struct size check if the amount of data returned was zero. This is what the old code did (effectively) before the the struct size check changed. (Patch just posted to -current). David. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message