r2791 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Tue Jun 24 20:09:38 CEST 2008
Author: phk
Date: 2008-06-24 20:09:38 +0200 (Tue, 24 Jun 2008)
New Revision: 2791
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_vrt_re.c
trunk/varnish-cache/bin/varnishd/cache_ws.c
Log:
Never release more bytes than there is room for.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2008-06-24 11:46:24 UTC (rev 2790)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2008-06-24 18:09:38 UTC (rev 2791)
@@ -691,6 +691,8 @@
static inline void
Tadd(txt *t, const char *p, int l)
{
+ Tcheck(*t);
+
if (l <= 0) {
} if (t->b + l < t->e) {
memcpy(t->b, p, l);
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-24 11:46:24 UTC (rev 2790)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-24 18:09:38 UTC (rev 2791)
@@ -110,7 +110,7 @@
regex_t *t;
int i, l;
txt res;
- char *p;
+ char *b0;
const char *s;
unsigned u, x;
@@ -124,8 +124,9 @@
if (i == REG_NOMATCH)
return(str);
+VSL(SLT_Debug, sp->fd, "REGSUB {");
u = WS_Reserve(sp->http->ws, 0);
- res.e = res.b = p = sp->http->ws->f;
+ res.e = res.b = b0 = sp->http->ws->f;
res.e += u;
do {
@@ -163,6 +164,7 @@
return (str);
}
Tcheck(res);
- WS_Release(sp->http->ws, p - res.b);
- return (p);
+ WS_Release(sp->http->ws, b0 - res.b);
+VSL(SLT_Debug, sp->fd, "REGSUB }");
+ return (b0);
}
Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ws.c 2008-06-24 11:46:24 UTC (rev 2790)
+++ trunk/varnish-cache/bin/varnishd/cache_ws.c 2008-06-24 18:09:38 UTC (rev 2791)
@@ -167,6 +167,7 @@
WS_Release(struct ws *ws, unsigned bytes)
{
WS_Assert(ws);
+ assert(bytes <= ws->e - ws->f);
DSL(0x02, SLT_Debug, 0, "WS_Release(%p, %u)", ws, bytes);
assert(ws->r != NULL);
assert(ws->f + bytes <= ws->r);
More information about the varnish-commit
mailing list