Date: Sun, 22 Mar 2015 17:11:10 +0100 From: Tijl Coosemans <tijl@FreeBSD.org> To: Ian Lepore <ian@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r279993 - in head/sys: dev/cxgb dev/cxgbe kern vm Message-ID: <20150322171110.2af31564@kalimero.tijl.coosemans.org> In-Reply-To: <201503141708.t2EH8TdR074383@svn.freebsd.org> References: <201503141708.t2EH8TdR074383@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--MP_/ycIkp_kwvfn.i6.Tw.o7FzR Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sat, 14 Mar 2015 17:08:29 +0000 (UTC) Ian Lepore <ian@FreeBSD.org> wrote: > Author: ian > Date: Sat Mar 14 17:08:28 2015 > New Revision: 279993 > URL: https://svnweb.freebsd.org/changeset/base/279993 > > Log: > 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.) Can you review the attached patch? The KERN_PROC_ENV sysctl is also binary (zero-terminated strings). Adding an extra \0 at the end makes some programs think there's an extra empty environment variable. It causes console-kit-daemon to crash for instance. I suspect a similar patch may be needed for KERN_PROC_ARGS. --MP_/ycIkp_kwvfn.i6.Tw.o7FzR Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=kern_proc_env.patch Index: sys/kern/kern_proc.c =================================================================== --- sys/kern/kern_proc.c (revision 280322) +++ sys/kern/kern_proc.c (working copy) @@ -1904,6 +1904,7 @@ sysctl_kern_proc_env(SYSCTL_HANDLER_ARGS } sbuf_new_for_sysctl(&sb, NULL, GET_PS_STRINGS_CHUNK_SZ, req); + sbuf_clear_flags(&sb, SBUF_INCLUDENUL); error = proc_getenvv(curthread, p, &sb); error2 = sbuf_finish(&sb); PRELE(p); --MP_/ycIkp_kwvfn.i6.Tw.o7FzR--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150322171110.2af31564>