From b97fa22cd62fa2bb7daf1c4d8fc30ed17dc4e0ec Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sat, 14 Mar 2015 18:42:30 +0000 Subject: [PATCH] Use sbuf_new_for_sysctl() instead of plain sbuf_new() to ensure sysctl string returned to userland is nulterminated. PR: 195668 --- sys/kern/sched_ule.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index d394d9f56ae..17371e7fe25 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -2830,7 +2830,7 @@ sysctl_kern_sched_topology_spec(SYSCTL_HANDLER_ARGS) KASSERT(cpu_top != NULL, ("cpu_top isn't initialized")); - topo = sbuf_new(NULL, NULL, 500, SBUF_AUTOEXTEND); + topo = sbuf_new_for_sysctl(NULL, NULL, 512, req); if (topo == NULL) return (ENOMEM); @@ -2839,8 +2839,7 @@ sysctl_kern_sched_topology_spec(SYSCTL_HANDLER_ARGS) sbuf_printf(topo, "\n"); if (err == 0) { - sbuf_finish(topo); - err = SYSCTL_OUT(req, sbuf_data(topo), sbuf_len(topo)); + err = sbuf_finish(topo); } sbuf_delete(topo); return (err);