svn commit: r279932 - head/sys/vm

Ian Lepore ian at freebsd.org
Thu Mar 12 23:31:04 UTC 2015


On Thu, 2015-03-12 at 17:02 -0400, Ryan Stone wrote:
> On Thu, Mar 12, 2015 at 2:06 PM, Ian Lepore <ian at freebsd.org> wrote:
> 
> >   Nullterminate strings returned via sysctl.
> >
> >   PR:           195668
> >
> 
> To quote the manpage:
> 
> > The *sbuf* family of functions allows one to safely
> > allocate, construct and release bounded null-terminated
> > strings in kernel space.
> 
> IMO the sbuf API is broken if we have to explicitly null-terminate the
> string ourselves.

If we want the nullterm to be counted in the length of data in the
buffer (and thus get transmitted back across the syscall boundary) we
need to put an explicit counted nullterm byte into the buffer.

I had started down the path of making that (counting the nullterm byte
as part of the data in the buffer) a feature of sbuf that you could set
with a flag, but then whoever added sbuf_new_for_sysctl() didn't
propagate the flags field through the new function and I decided to not
go off into the weeds making a new flavor of that takes flags.

-- Ian



More information about the svn-src-all mailing list