From c41531804095b0be9d7da837b35591d56d152d46 Mon Sep 17 00:00:00 2001 From: Artyom Belov Date: Fri, 18 Sep 2020 14:36:38 +0300 Subject: [PATCH] copying each header to the cache, we must leave space for the string header, also, if there are duplicate headers, then we must write the duplicate header. earlier in the presence of duplicates, there was a double shift at the beginning of the copying procedure CSTR_MOVE_HDR CSTR_WRITE_HDR *CSTR_MOVE_HDR* *CSTR_MOVE_HDR* CSTR_WRITE_HDR --- tempesta_fw/cache.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tempesta_fw/cache.c b/tempesta_fw/cache.c index 13f28142e..0e6da7d23 100644 --- a/tempesta_fw/cache.c +++ b/tempesta_fw/cache.c @@ -1152,23 +1152,22 @@ tfw_cache_h2_copy_hdr(TfwCacheEntry *ce, char **p, TdbVRec **trec, TfwStr *hdr, return -ENOMEM; } - CSTR_MOVE_HDR(); - if (TFW_STR_DUP(hdr)) { - CSTR_WRITE_HDR(TFW_STR_DUPLICATE, hdr->nchunks); CSTR_MOVE_HDR(); + CSTR_WRITE_HDR(TFW_STR_DUPLICATE, hdr->nchunks); } TFW_STR_FOR_EACH_DUP(dup, hdr, dup_end) { - unsigned int prev_len = ce->hdr_len; + unsigned int prev_len; if (dupl) { TFW_STR_INIT(&s_nm); TFW_STR_INIT(&s_val); tfw_http_hdr_split(dup, &s_nm, &s_val, true); st_index = dup->hpack_idx; - CSTR_MOVE_HDR(); } + CSTR_MOVE_HDR(); + prev_len = ce->hdr_len; if (st_index) { if (tfw_cache_h2_copy_int(&ce->hdr_len, st_index, 0xF,