From owner-freebsd-bugs@FreeBSD.ORG Sat Sep 5 21:00:14 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1AD861065679 for ; Sat, 5 Sep 2009 21:00:14 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E78408FC17 for ; Sat, 5 Sep 2009 21:00:13 +0000 (UTC) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n85L0DpO030454 for ; Sat, 5 Sep 2009 21:00:13 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n85L0Dbl030453; Sat, 5 Sep 2009 21:00:13 GMT (envelope-from gnats) Resent-Date: Sat, 5 Sep 2009 21:00:13 GMT Resent-Message-Id: <200909052100.n85L0Dbl030453@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Bruce Cran Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB427106566B for ; Sat, 5 Sep 2009 20:50:25 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id DA9748FC08 for ; Sat, 5 Sep 2009 20:50:25 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n85KoPfa080126 for ; Sat, 5 Sep 2009 20:50:25 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n85KoP4X080125; Sat, 5 Sep 2009 20:50:25 GMT (envelope-from nobody) Message-Id: <200909052050.n85KoP4X080125@www.freebsd.org> Date: Sat, 5 Sep 2009 20:50:25 GMT From: Bruce Cran To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/138557: [patch] fix truncated witness sysctl string due to incorrect use of sizeof X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 21:00:14 -0000 >Number: 138557 >Category: kern >Synopsis: [patch] fix truncated witness sysctl string due to incorrect use of sizeof >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Sep 05 21:00:13 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Bruce Cran >Release: 8.0-BETA3 >Organization: >Environment: FreeBSD gluon.draftnet 8.0-BETA3 FreeBSD 8.0-BETA3 #1: Fri Sep 4 09:20:32 BST 2009 brucec@gluon.draftnet:/usr/obj/usr/src/sys/GENERIC i386 >Description: In sys/kern/subr_witness.c the strings "Witness not running" and "Witness is still cold" get truncated to "Witn" in the sysctl tree because sizeof is used instead of strlen. >How-To-Repeat: sysctl debug.witness.watch=0 sysctl debug.witness.badstacks >Fix: Patch attached with submission follows: --- subr_witness.c.orig 2009-09-05 21:24:40.000000000 +0100 +++ subr_witness.c 2009-09-05 21:25:42.000000000 +0100 @@ -2378,11 +2378,11 @@ tmp_w1 = NULL; tmp_w2 = NULL; if (witness_watch < 1) { - error = SYSCTL_OUT(req, w_notrunning, sizeof(w_notrunning)); + error = SYSCTL_OUT(req, w_notrunning, strlen(w_notrunning) + 1); return (error); } if (witness_cold) { - error = SYSCTL_OUT(req, w_stillcold, sizeof(w_stillcold)); + error = SYSCTL_OUT(req, w_stillcold, strlen(w_stillcold) + 1); return (error); } error = 0; @@ -2530,11 +2530,11 @@ int error; if (witness_watch < 1) { - error = SYSCTL_OUT(req, w_notrunning, sizeof(w_notrunning)); + error = SYSCTL_OUT(req, w_notrunning, strlen(w_notrunning) + 1); return (error); } if (witness_cold) { - error = SYSCTL_OUT(req, w_stillcold, sizeof(w_stillcold)); + error = SYSCTL_OUT(req, w_stillcold, strlen(w_stillcold) + 1); return (error); } error = 0; >Release-Note: >Audit-Trail: >Unformatted: