[experimental-ims] d2b5440 Clamp # of iovec to IOV_MAX

Geoff Simmons geoff at varnish-cache.org
Tue Feb 14 17:49:35 CET 2012


commit d2b54402c34166044f745f8d92348970e26472b4
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Feb 14 13:58:04 2012 +0000

    Clamp # of iovec to IOV_MAX

diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c
index 00b3a9e..3685bec 100644
--- a/bin/varnishd/cache/cache_wrw.c
+++ b/bin/varnishd/cache/cache_wrw.c
@@ -37,6 +37,7 @@
 #include <sys/types.h>
 #include <sys/uio.h>
 
+#include <limits.h>
 #include <stdio.h>
 
 #include "cache.h"
@@ -82,6 +83,8 @@ WRW_Reserve(struct worker *wrk, int *fd)
 	u = WS_Reserve(wrk->aws, 0);
 	u = PRNDDN(u);
 	u /= sizeof(struct iovec);
+	if (u > IOV_MAX)
+		u = IOV_MAX;
 	AN(u);
 	wrw->iov = (void*)PRNDUP(wrk->aws->f);
 	wrw->siov = u;



More information about the varnish-commit mailing list