]> err.no Git - varnish/commitdiff
NB: some of this commit sneaked into #2757
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 21 Jun 2008 18:55:13 +0000 (18:55 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 21 Jun 2008 18:55:13 +0000 (18:55 +0000)
Fix http_GetHdrField() to use the correct RFC2616 syntax for tokens
and separators.

Fixes ticket #255.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2758 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_http.c
varnish-cache/bin/varnishd/rfc2616.c

index 5826023fe7b082d6a6561b2f2d3dbf5f9aa5316b..8985b0b56660c94538572806b0339ef011846c48 100644 (file)
@@ -269,22 +269,25 @@ http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char
                        h++;
                        continue;
                }
+               /* Check for substrings before memcmp() */
                if ((h + fl == e || vct_issepctl(h[fl])) &&
                    !memcmp(h, field, fl)) {
                        /* got it */
                        h += fl;
                        if (ptr != NULL) {
-                               while (vct_issp(*h))
+                               /* Skip whitespace, looking for '=' */
+                               while (*h && vct_issp(*h))
                                        h++;
                                if (*h == '=') {
                                        h++;
-                                       while (vct_issp(*h))
+                                       while (*h && vct_issp(*h))
                                                h++;
                                        *ptr = h;
                                }
                        }
                        return (1);
                }
+               /* Skip token */
                while (*h && !vct_issepctl(*h)) 
                        h++;
        }
index c153c21d9a8252f0d17c00b836b998c9ac5a2f8d..52762aa91f622fbb3de5b660b7811c18544dbac0 100644 (file)
@@ -110,9 +110,9 @@ RFC2616_Ttl(const struct sess *sp, const struct http *hp, struct object *obj)
        retirement_age = INT_MAX;
 
        u1 = u2 = 0;
-       if (http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) ||
-           http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) {
-               AN(p);
+       if ((http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) ||
+           http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) &&
+           p != NULL {
                u1 = strtoul(p, NULL, 0);
                u2 = 0;
                if (http_GetHdr(hp, H_Age, &p)) {