[master] a3d47c2 Handle WS_Reserve() overflows gracefully

Federico G. Schwindt fgsch at lodoss.net
Wed Jan 13 20:27:11 CET 2016


commit a3d47c258fb7938f67a053f6d041257edb69afe9
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Wed Jan 13 19:18:36 2016 +0000

    Handle WS_Reserve() overflows gracefully
    
    If we don't have enough space for the requested size, don't xxxassert,
    just mark the overflow and return 0.
    
    Discussed with daghf@ and dridi at .

diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
index 7070f1a..a825fdc 100644
--- a/bin/varnishd/cache/cache_ws.c
+++ b/bin/varnishd/cache/cache_ws.c
@@ -217,7 +217,10 @@ WS_Reserve(struct ws *ws, unsigned bytes)
 	if (bytes != 0 && bytes < b2)
 		b2 = PRNDUP(bytes);
 
-	xxxassert(ws->f + b2 <= ws->e);
+	if (ws->f + b2 > ws->e) {
+		WS_MarkOverflow(ws);
+		return (0);
+	}
 	ws->r = ws->f + b2;
 	DSL(DBG_WORKSPACE, 0, "WS_Reserve(%p, %u/%u) = %u",
 	    ws, b2, bytes, pdiff(ws->f, ws->r));



More information about the varnish-commit mailing list