diff options
author | Ian Lepore <ian@FreeBSD.org> | 2015-03-14 17:08:28 +0000 |
---|---|---|
committer | Ian Lepore <ian@FreeBSD.org> | 2015-03-14 17:08:28 +0000 |
commit | 1eafc07856a9d787f1e383497f37c624f5b7c72c (patch) | |
tree | 15f05881ac7348ea6410bf891ab1547fb695271e /sys/kern/kern_proc.c | |
parent | f4d281428f9eb458ffc19df9a1ed9e2af0950b8e (diff) | |
download | src-1eafc07856a9d787f1e383497f37c624f5b7c72c.tar.gz src-1eafc07856a9d787f1e383497f37c624f5b7c72c.zip |
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.)
Remove explicit adding of a nulterm byte in a couple places now that it
gets done automatically by the sbuf drain code.
PR: 195668
Notes
Notes:
svn path=/head/; revision=279993
Diffstat (limited to 'sys/kern/kern_proc.c')
-rw-r--r-- | sys/kern/kern_proc.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2aa5c4a3d4cc..a607d7b191b0 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1273,6 +1273,7 @@ sysctl_out_proc(struct proc *p, struct sysctl_req *req, int flags, pid = p->p_pid; sbuf_new_for_sysctl(&sb, (char *)&ki, sizeof(ki), req); + sbuf_clear_flags(&sb, SBUF_INCLUDENUL); error = kern_proc_out(p, &sb, flags); error2 = sbuf_finish(&sb); sbuf_delete(&sb); @@ -1934,6 +1935,7 @@ sysctl_kern_proc_auxv(SYSCTL_HANDLER_ARGS) return (0); } sbuf_new_for_sysctl(&sb, NULL, GET_PS_STRINGS_CHUNK_SZ, req); + sbuf_clear_flags(&sb, SBUF_INCLUDENUL); error = proc_getauxv(curthread, p, &sb); error2 = sbuf_finish(&sb); PRELE(p); @@ -2421,6 +2423,7 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS) name = (int *)arg1; sbuf_new_for_sysctl(&sb, NULL, sizeof(struct kinfo_vmentry), req); + sbuf_clear_flags(&sb, SBUF_INCLUDENUL); error = pget((pid_t)name[0], PGET_CANDEBUG | PGET_NOTWEXIT, &p); if (error != 0) { sbuf_delete(&sb); |