Use sbuf_new_for_sysctl() instead of plain sbuf_new() to ensure sysctl

string returned to userland is nulterminated.

PR:           195668
This commit is contained in:
Ian Lepore 2015-03-14 18:42:30 +00:00
parent 751ccc429d
commit b97fa22cd6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=279999

View File

@ -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, "</groups>\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);