]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cache: properly ignore unparsable max-age in quotes
authorWilly Tarreau <w@1wt.eu>
Mon, 8 Nov 2021 11:09:27 +0000 (12:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 8 Nov 2021 11:09:27 +0000 (12:09 +0100)
When "max-age" or "s-maxage" receive their values in quotes, the pointer
to the integer to be parsed is advanced by one, but the error pointer
check doesn't consider this advanced offset, so it will not match a
parse error such as max-age="a" and will take the value zero instead.

This probably needs to be backported, though it's unsure it has any
effect in the real world.

src/cache.c

index 9c108ae5370ba767a6e05ece9a29bfc320a0855a..287ff5325bef8c347dadfeba661e22487816b434 100644 (file)
@@ -783,7 +783,7 @@ int http_calc_maxage(struct stream *s, struct cache *cache, int *true_maxage)
                        chunk_memcat(chk, "", 1);
                        offset = (*chk->area == '"') ? 1 : 0;
                        smaxage = strtol(chk->area + offset, &endptr, 10);
-                       if (unlikely(smaxage < 0 || endptr == chk->area))
+                       if (unlikely(smaxage < 0 || endptr == chk->area + offset))
                                return -1;
                }
 
@@ -795,7 +795,7 @@ int http_calc_maxage(struct stream *s, struct cache *cache, int *true_maxage)
                        chunk_memcat(chk, "", 1);
                        offset = (*chk->area == '"') ? 1 : 0;
                        maxage = strtol(chk->area + offset, &endptr, 10);
-                       if (unlikely(maxage < 0 || endptr == chk->area))
+                       if (unlikely(maxage < 0 || endptr == chk->area + offset))
                                return -1;
                }
        }