Date: Sat, 5 Sep 2009 20:50:25 GMT From: Bruce Cran <bruce@cran.org.uk> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/138557: [patch] fix truncated witness sysctl string due to incorrect use of sizeof Message-ID: <200909052050.n85KoP4X080125@www.freebsd.org> Resent-Message-ID: <200909052100.n85L0Dbl030453@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909052050.n85KoP4X080125>