From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 9 00:11:56 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 970EB16A4CE for ; Wed, 9 Jun 2004 00:11:56 +0000 (GMT) Received: from grunt10.ihug.co.nz (grunt10.ihug.co.nz [203.109.254.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id BF98443D5C for ; Wed, 9 Jun 2004 00:11:55 +0000 (GMT) (envelope-from mjl@luckie.org.nz) Received: from 203-118-173-80.adsl.ihug.co.nz (lycra.luckie.org.nz) [203.118.173.80] by grunt10.ihug.co.nz with esmtp (Exim 3.35 #1 (Debian)) id 1BXqh8-0002sf-00; Wed, 09 Jun 2004 12:11:54 +1200 Received: from mjl (helo=localhost) by lycra.luckie.org.nz with local-esmtp (Exim 4.34; FreeBSD) id 1BXqh7-0006eH-Gb; Wed, 09 Jun 2004 12:11:53 +1200 Date: Wed, 9 Jun 2004 12:11:53 +1200 (NZST) From: Matthew Luckie To: hackers@freebsd.org Message-ID: <20040609115052.D24917@lycra.luckie.org.nz> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Mailman-Approved-At: Wed, 09 Jun 2004 12:36:24 +0000 cc: mjl@luckie.org.nz Subject: use of kernel_sysctl X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2004 00:11:56 -0000 in sys/netsmb/smb_subr.c the following code fragment is used: [FreeBSD 4.10] int smb_checksmp(void) { int name[2]; int olen, ncpu, plen, error; name[0] = CTL_HW; name[1] = HW_NCPU; error = kernel_sysctl(curproc, name, 2, &ncpu, &olen, NULL, 0, &plen); if (error) return error; olen is passed without having its value set. on input, i'd expect it to specify sizeof(ncpu). looking in kernel_sysctl.c, *olen is used by kernel_sysctl. I had a quick grep through the source and saw a similar code fragment to this in nwfs. So it could be either that I've got it wrong and I'm not understanding something, or the code was used as a template in more than one place and was bug-for-bug copied. Feedback appreciated, cc'd Matthew