summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_sbuf.c
diff options
context:
space:
mode:
authormdf <mdf@FreeBSD.org>2010-09-09 18:33:46 +0000
committermdf <mdf@FreeBSD.org>2010-09-09 18:33:46 +0000
commitbc5468425338dbee3cd3da7d6bc2a1290ba8d2ce (patch)
treefb245e2e8ce30565e64963b84e00c3b93d9bc280 /sys/kern/subr_sbuf.c
parenta7b4070f1f143143442a97cffdf24fc59814851f (diff)
downloadFreeBSD-src-bc5468425338dbee3cd3da7d6bc2a1290ba8d2ce.zip
FreeBSD-src-bc5468425338dbee3cd3da7d6bc2a1290ba8d2ce.tar.gz
Add a drain function for struct sysctl_req, and use it for a variety of
handlers, some of which had to do awkward things to get a large enough FIXEDLEN buffer. Note that some sysctl handlers were explicitly outputting a trailing NUL byte. This behaviour was preserved, though it should not be necessary. Reviewed by: phk
Diffstat (limited to 'sys/kern/subr_sbuf.c')
-rw-r--r--sys/kern/subr_sbuf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c
index d7b57a5..58964fb 100644
--- a/sys/kern/subr_sbuf.c
+++ b/sys/kern/subr_sbuf.c
@@ -305,8 +305,8 @@ sbuf_drain(struct sbuf *s)
SBUF_SETFLAG(s, SBUF_OVERFLOWED);
return (s->s_error);
}
-
- KASSERT(len > 0, ("Drain must either error or work!"));
+ KASSERT(len > 0 && len <= s->s_len,
+ ("Bad drain amount %d for sbuf %p", len, s));
s->s_len -= len;
/*
* Fast path for the expected case where all the data was
OpenPOWER on IntegriCloud