kern/138557: [patch] fix truncated witness sysctl string due to
incorrect use of sizeof
Bruce Cran
bruce at cran.org.uk
Sat Sep 5 21:00:14 UTC 2009
>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 at 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:
More information about the freebsd-bugs
mailing list