[master] 5c18588 Clip negative values before they do any damage.

Poul-Henning Kamp phk at FreeBSD.org
Mon Mar 16 21:43:38 CET 2015


commit 5c185885b88b511db4f99e3f291985655d865202
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Mar 16 20:42:44 2015 +0000

    Clip negative values before they do any damage.

diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index 01f13e8..4777a5f 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -230,11 +230,14 @@ VCL_VOID __match_proto__(td_std_cache_req_body)
 vmod_cache_req_body(VRT_CTX, VCL_BYTES size)
 {
 	int result;
+	ssize_t ss;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
-	result = VRT_CacheReqBody(ctx, size);
-	VSLb(ctx->vsl, SLT_Debug, "VRT_CacheReqBody(%zu): %d",
-	    (size_t)size, result);
+	if (size < 0)
+		size = 0;
+	ss = (ssize_t)size;
+	result = VRT_CacheReqBody(ctx, ss);
+	VSLb(ctx->vsl, SLT_Debug, "VRT_CacheReqBody(%zd): %d", ss, result);
 }
 
 VCL_STRING __match_proto__(td_std_strstr)



More information about the varnish-commit mailing list