r4199 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Tue Aug 18 14:19:10 CEST 2009


Author: phk
Date: 2009-08-18 14:19:10 +0200 (Tue, 18 Aug 2009)
New Revision: 4199

Modified:
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Don't allocate if we do not fit in the segment.



Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-08-18 12:03:06 UTC (rev 4198)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-08-18 12:19:10 UTC (rev 4199)
@@ -892,7 +892,6 @@
 	} else {
 		sg->offset = sg2->offset + sg2->length;
 		assert(sg->offset < sc->mediasize);
-		assert(sg->offset + sg2->length < sc->mediasize);
 	}
 	sg->length = sc->aim_segl;
 	sg->length &= ~7;
@@ -1093,6 +1092,10 @@
 	sg = sc->cur_seg;
 
 	/* XXX: size fit check */
+	if (sg->next_addr + sizeof *ss + size > sg->length) {
+		Lck_Unlock(&sc->mtx);
+		return (NULL);
+	}
 	AN(sg->next_addr);
 	ss = (void *)(sc->ptr + sg->next_addr);
 	sg->next_addr += size + sizeof *ss;



More information about the varnish-commit mailing list