Mailing List Archive

r3163 - trunk/varnish-cache/lib/libvcl
Author: tfheen
Date: 2008-09-07 09:47:26 +0200 (Sun, 07 Sep 2008)
New Revision: 3163

Modified:
trunk/varnish-cache/lib/libvcl/vcc_action.c
Log:
Don't segfault on purge.hash() with NULL string. Fixes #307.


Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c 2008-09-03 13:26:36 UTC (rev 3162)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2008-09-07 07:47:26 UTC (rev 3163)
@@ -336,22 +336,26 @@
static void
parse_purge_url(struct tokenlist *tl)
{
+ struct var *vp;

vcc_NextToken(tl);

- Fb(tl, 1, "VRT_purge(");
-
Expect(tl, '(');
vcc_NextToken(tl);

- if (!vcc_StringVal(tl)) {
+ vp = vcc_FindVar(tl, tl->t, vcc_vars);
+ ERRCHK(tl);
+ assert(vp != NULL);
+ if (vp->fmt != STRING) {
vcc_ExpectedStringval(tl);
return;
}

+ Fb(tl, 1, "if (%s) VRT_purge(%s, 0);\n", vp->rname, vp->rname);
+ vcc_NextToken(tl);
+
Expect(tl, ')');
vcc_NextToken(tl);
- Fb(tl, 0, ", 0);\n");
}
r3163 - trunk/varnish-cache/lib/libvcl [ In reply to ]
In message <20080907074726.BF0941EC1FF at projects.linpro.no>, tfheen at projects.lin
pro.no writes:
>Author: tfheen
>Date: 2008-09-07 09:47:26 +0200 (Sun, 07 Sep 2008)
>New Revision: 3163
>
>Modified:
> trunk/varnish-cache/lib/libvcl/vcc_action.c
>Log:
>Don't segfault on purge.hash() with NULL string. Fixes #307.

I am not happy with this commit, it needlessly and counter-intuitively
restricts the argument to a variable, it should be a free string
value like it was before and is everywhere else.

Poul-Henning

>
>
>Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
>===================================================================
>--- trunk/varnish-cache/lib/libvcl/vcc_action.c 2008-09-03 13:26:36 UTC (rev 3162)
>+++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2008-09-07 07:47:26 UTC (rev 3163)
>@@ -336,22 +336,26 @@
> static void
> parse_purge_url(struct tokenlist *tl)
> {
>+ struct var *vp;
>
> vcc_NextToken(tl);
>
>- Fb(tl, 1, "VRT_purge(");
>-
> Expect(tl, '(');
> vcc_NextToken(tl);
>
>- if (!vcc_StringVal(tl)) {
>+ vp = vcc_FindVar(tl, tl->t, vcc_vars);
>+ ERRCHK(tl);
>+ assert(vp != NULL);
>+ if (vp->fmt != STRING) {
> vcc_ExpectedStringval(tl);
> return;
> }
>
>+ Fb(tl, 1, "if (%s) VRT_purge(%s, 0);\n", vp->rname, vp->rname);
>+ vcc_NextToken(tl);
>+
> Expect(tl, ')');
> vcc_NextToken(tl);
>- Fb(tl, 0, ", 0);\n");
> }
>
>
>
>_______________________________________________
>varnish-commit mailing list
>varnish-commit at projects.linpro.no
>http://projects.linpro.no/mailman/listinfo/varnish-commit
>

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.