On Sat, 14 Mar 2015 17:08:29 +0000 (UTC) Ian Lepore <i...@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.
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);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"