From 28349245135d7fa48bf3b0df5d1c18371bddd623 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Tue, 17 Mar 2015 20:56:24 +0000 Subject: [PATCH] In sbuf_new_for_sysctl(), default the buffer size to 64 bytes if the passed-in pointer is NULL and the length is zero. --- sys/kern/kern_sysctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 97ee63428531..c02b61530a1a 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1807,6 +1807,9 @@ sbuf_new_for_sysctl(struct sbuf *s, char *buf, int length, struct sysctl_req *req) { + /* Supply a default buffer size if none given. */ + if (buf == NULL && length == 0) + length = 64; s = sbuf_new(s, buf, length, SBUF_FIXEDLEN | SBUF_INCLUDENUL); sbuf_set_drain(s, sbuf_sysctl_drain, req); return (s);