[4.1] d699e14 Make VSB_bcat() take a ssize_t to be able to assert non-negative lengths.
Lasse Karstensen
lkarsten at varnish-software.com
Thu Jan 14 15:15:09 CET 2016
commit d699e1406a5713f54f07368536bd8b41ff941167
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Dec 15 22:50:21 2015 +0000
Make VSB_bcat() take a ssize_t to be able to assert non-negative lengths.
Spotted by: FlexeLint
diff --git a/include/vsb.h b/include/vsb.h
index 61b64c0..4b34314 100644
--- a/include/vsb.h
+++ b/include/vsb.h
@@ -61,7 +61,7 @@ struct vsb *VSB_new(struct vsb *, char *, int, int);
#define VSB_new_auto() \
VSB_new(NULL, NULL, 0, VSB_AUTOEXTEND)
void VSB_clear(struct vsb *);
-int VSB_bcat(struct vsb *, const void *, size_t);
+int VSB_bcat(struct vsb *, const void *, ssize_t);
int VSB_cat(struct vsb *, const char *);
int VSB_printf(struct vsb *, const char *, ...)
__v_printflike(2, 3);
diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c
index ad98c8a..7b9380a 100644
--- a/lib/libvarnish/vsb.c
+++ b/lib/libvarnish/vsb.c
@@ -276,13 +276,16 @@ VSB_put_byte(struct vsb *s, int c)
* Append a byte string to an vsb.
*/
int
-VSB_bcat(struct vsb *s, const void *buf, size_t len)
+VSB_bcat(struct vsb *s, const void *buf, ssize_t len)
{
assert_VSB_integrity(s);
assert_VSB_state(s, 0);
+ assert(len >= 0);
if (s->s_error != 0)
return (-1);
+ if (len == 0)
+ return (0);
_vsb_indent(s);
if (len > VSB_FREESPACE(s)) {
if (VSB_extend(s, len - VSB_FREESPACE(s)) < 0)
More information about the varnish-commit
mailing list