[4.1] 5ddcf6a check for overrun before looking at the next vsm record

Lasse Karstensen lkarsten at varnish-software.com
Wed Jun 1 14:26:06 CEST 2016


commit 5ddcf6a2b26da27c4bd3871f4303cdedb41b3433
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed May 11 14:47:10 2016 +0200

    check for overrun before looking at the next vsm record
    
    Fixes #1873

diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c
index e9daab0..33d08e3 100644
--- a/lib/libvarnishapi/vsl_cursor.c
+++ b/lib/libvarnishapi/vsl_cursor.c
@@ -126,6 +126,10 @@ vslc_vsm_next(const struct VSL_cursor *cursor)
 	CHECK_OBJ_NOTNULL(c->vsm, VSM_MAGIC);
 
 	while (1) {
+		i = vslc_vsm_check(&c->cursor, &c->next);
+		if (i <= 0)
+			return (-3); /* Overrun */
+
 		t = *(volatile const uint32_t *)c->next.ptr;
 		AN(t);
 
@@ -147,10 +151,6 @@ vslc_vsm_next(const struct VSL_cursor *cursor)
 			return (0);	/* No new records available */
 		}
 
-		i = vslc_vsm_check(&c->cursor, &c->next);
-		if (i <= 0)
-			return (-3); /* Overrun */
-
 		c->cursor.rec = c->next;
 		c->next.ptr = VSL_NEXT(c->next.ptr);
 



More information about the varnish-commit mailing list