From owner-freebsd-bugs Mon Dec 24 6:50:10 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 4D5E037B417 for ; Mon, 24 Dec 2001 06:50:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id fBOEo1s70486; Mon, 24 Dec 2001 06:50:01 -0800 (PST) (envelope-from gnats) Received: from melchior.cuivre.fr.eu.org (melchior.enst.fr [137.194.161.6]) by hub.freebsd.org (Postfix) with ESMTP id 4E00237B417 for ; Mon, 24 Dec 2001 06:49:12 -0800 (PST) Received: from melusine.cuivre.fr.eu.org (melusine.enst.fr [137.194.160.34]) by melchior.cuivre.fr.eu.org (Postfix) with ESMTP id 2BBD57A40 for ; Mon, 24 Dec 2001 15:49:10 +0100 (CET) Received: by melusine.cuivre.fr.eu.org (Postfix, from userid 1000) id 8609460; Mon, 24 Dec 2001 15:49:10 +0100 (CET) Message-Id: <20011224144910.8609460@melusine.cuivre.fr.eu.org> Date: Mon, 24 Dec 2001 15:49:10 +0100 (CET) From: Thomas Quinot Reply-To: Thomas Quinot To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/33151: sbin/sysctl: unreachable and duplicated code [patch included] Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 33151 >Category: bin >Synopsis: sbin/sysctl: unreachable and duplicated code [patch included] >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Dec 24 06:50:00 PST 2001 >Closed-Date: >Last-Modified: >Originator: Thomas Quinot >Release: FreeBSD 4.4-STABLE i386 >Organization: >Environment: System: FreeBSD melusine.cuivre.fr.eu.org 4.4-STABLE FreeBSD 4.4-STABLE #3: Mon Dec 17 01:07:53 CET 2001 root@melusine.cuivre.fr.eu.org:/usr/obj/usr/src/sys/MELUSINE i386 >Description: * In parse(), when a value is given for a CTLTYPE_QUAD variable, newval and newsize erroneously fail to be set because of an early "break". * show_var() contains code that duplicates the functionality of the oidfmt() function. >How-To-Repeat: UTSL. >Fix: --- sysctl.c.dist Mon Dec 24 14:31:10 2001 +++ sysctl.c Mon Dec 24 15:39:37 2001 @@ -213,7 +213,6 @@ case CTLTYPE_STRING: break; case CTLTYPE_QUAD: - break; sscanf(newval, "%qd", &quadval); newval = &quadval; newsize = sizeof(quadval); @@ -425,16 +424,8 @@ return (0); } - qoid[1] = 4; - j = sizeof(buf); - i = sysctl(qoid, nlen + 2, buf, &j, 0, 0); - if (i || !j) - err(1, "sysctl fmt %d %d %d", i, j, errno); - - kind = *(u_int *)buf; - - fmt = (char *)(buf + sizeof(u_int)); - + fmt = buf; + oidfmt(oid, nlen, fmt, &kind); p = val; switch (*fmt) { case 'A': >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message