From bec66151a604a53cc543ac3a478dfd8cef61446c Mon Sep 17 00:00:00 2001 From: Malcolm Seyd Date: Mon, 10 Oct 2022 18:42:03 -0700 Subject: [PATCH] fix bug parsing repeatable http headers --- net/http/parsehttpmessage.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/http/parsehttpmessage.c b/net/http/parsehttpmessage.c index c7b560dbe..85010465c 100644 --- a/net/http/parsehttpmessage.c +++ b/net/http/parsehttpmessage.c @@ -236,8 +236,12 @@ int ParseHttpMessage(struct HttpMessage *r, const char *p, size_t n) { unsigned c2; struct HttpHeader *p1, *p2; p1 = r->xheaders.p; - c2 = r->xheaders.c + 2; - c2 = c2 >> 1; + c2 = r->xheaders.c; + if (c2 == 0) { + c2 = 1; + } else { + c2 = c2 * 2; + } if ((p2 = realloc(p1, c2 * sizeof(*p1)))) { r->xheaders.p = p2; r->xheaders.c = c2;