diff --git a/src/proto_http.c b/src/proto_http.c index 771e7c0e9..9068050a5 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -8163,9 +8163,11 @@ unsigned int http_get_hdr(const struct http_msg *msg, const char *hname, int hle if (-occ > found) return 0; /* OK now we have the last occurrence in [hist_ptr-1], and we need to - * find occurrence -occ, so we have to check [hist_ptr+occ]. + * find occurrence -occ. 0 <= hist_ptr < MAX_HDR_HISTORY, and we have + * -10 <= occ <= -1. So we have to check [hist_ptr%MAX_HDR_HISTORY+occ] + * to remain in the 0..9 range. */ - hist_ptr += occ; + hist_ptr += occ + MAX_HDR_HISTORY; if (hist_ptr >= MAX_HDR_HISTORY) hist_ptr -= MAX_HDR_HISTORY; *vptr = ptr_hist[hist_ptr];