mirror of
https://github.com/haproxy/haproxy.git
synced 2026-06-08 16:23:24 -04:00
BUG/MINOR: cache: Fix copy of value when parsing maxage
During maxage parsing, the size of the value was not properly computed when it was copied into the trash chunk. The name (max-age or s-maxage) must be skipped with the '=' character. But instead of doing a subtraction, and addition was performed, adding 2 extra bytes to the value used for the convertion to integer. In addition, the "chunk_memcat(chk, "", 1)" operation to add a trailing NULL-byte was replaced by "*(b_tail(chk)) = '\0'". It a bit easier to understand. This patch should be backported to all stable versions.
This commit is contained in:
parent
3a5189faba
commit
f1aac4a3b2
1 changed files with 4 additions and 4 deletions
|
|
@ -949,8 +949,8 @@ int http_calc_maxage(struct stream *s, struct cache *cache, int *true_maxage)
|
|||
if (value) {
|
||||
struct buffer *chk = get_trash_chunk();
|
||||
|
||||
chunk_memcat(chk, value, ctx.value.len - 8 + 1);
|
||||
chunk_memcat(chk, "", 1);
|
||||
chunk_memcat(chk, value, ctx.value.len - (8 + 1));
|
||||
*(b_tail(chk)) = '\0';
|
||||
offset = (*chk->area == '"') ? 1 : 0;
|
||||
smaxage = strtol(chk->area + offset, &endptr, 10);
|
||||
if (unlikely(smaxage < 0 || endptr == chk->area + offset))
|
||||
|
|
@ -961,8 +961,8 @@ int http_calc_maxage(struct stream *s, struct cache *cache, int *true_maxage)
|
|||
if (value) {
|
||||
struct buffer *chk = get_trash_chunk();
|
||||
|
||||
chunk_memcat(chk, value, ctx.value.len - 7 + 1);
|
||||
chunk_memcat(chk, "", 1);
|
||||
chunk_memcat(chk, value, ctx.value.len - (7 + 1));
|
||||
*(b_tail(chk)) = '\0';
|
||||
offset = (*chk->area == '"') ? 1 : 0;
|
||||
maxage = strtol(chk->area + offset, &endptr, 10);
|
||||
if (unlikely(maxage < 0 || endptr == chk->area + offset))
|
||||
|
|
|
|||
Loading…
Reference in a new issue