aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2015-03-14 17:08:28 +0000
committerIan Lepore <ian@FreeBSD.org>2015-03-14 17:08:28 +0000
commit1eafc07856a9d787f1e383497f37c624f5b7c72c (patch)
tree15f05881ac7348ea6410bf891ab1547fb695271e /sys/kern/kern_sysctl.c
parentf4d281428f9eb458ffc19df9a1ed9e2af0950b8e (diff)
downloadsrc-1eafc07856a9d787f1e383497f37c624f5b7c72c.tar.gz
src-1eafc07856a9d787f1e383497f37c624f5b7c72c.zip
Set the SBUF_INCLUDENUL flag in sbuf_new_for_sysctl() so that sysctl
strings returned to userland include the nulterm byte. Some uses of sbuf_new_for_sysctl() write binary data rather than strings; clear the SBUF_INCLUDENUL flag after calling sbuf_new_for_sysctl() in those cases. (Note that the sbuf code still automatically adds a nulterm byte in sbuf_finish(), but since it's not included in the length it won't get copied to userland along with the binary data.) Remove explicit adding of a nulterm byte in a couple places now that it gets done automatically by the sbuf drain code. PR: 195668
Notes
Notes: svn path=/head/; revision=279993
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index f429a7bfdba7..97ee63428531 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1807,7 +1807,7 @@ sbuf_new_for_sysctl(struct sbuf *s, char *buf, int length,
struct sysctl_req *req)
{
- s = sbuf_new(s, buf, length, SBUF_FIXEDLEN);
+ s = sbuf_new(s, buf, length, SBUF_FIXEDLEN | SBUF_INCLUDENUL);
sbuf_set_drain(s, sbuf_sysctl_drain, req);
return (s);
}