BUG/MINOR: cache: properly ignore unparsable max-age in quotes

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.
This commit is contained in:
Willy Tarreau 2021-11-08 12:09:27 +01:00
parent 49b0482ed4
commit 1f38bdb3f6

View 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;
}
}