]> git.ipfire.org Git - thirdparty/git.git/commitdiff
http: fix leak when redacting cookies from curl trace
authorJeff King <peff@peff.net>
Tue, 24 Sep 2024 21:59:14 +0000 (17:59 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Sep 2024 17:24:55 +0000 (10:24 -0700)
When redacting headers for GIT_TRACE_CURL, we build up a redacted cookie
header in a local strbuf, and then copy it into the output. But we
forget to release the temporary strbuf, leaking it for every cookie
header we show.

The other redacted headers don't run into this problem, since they're
able to work in-place in the output buffer. But the cookie parsing is
too complicated for that, since we redact the cookies individually.

This leak is triggered by the cookie tests in t5551.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http.c

diff --git a/http.c b/http.c
index 6c6cc5c822ad5ae741a9902aad35aa94cef2260d..cc136408c094bd430bf038e779c0c9093525390b 100644 (file)
--- a/http.c
+++ b/http.c
@@ -800,6 +800,7 @@ static int redact_sensitive_header(struct strbuf *header, size_t offset)
 
                strbuf_setlen(header, sensitive_header - header->buf);
                strbuf_addbuf(header, &redacted_header);
+               strbuf_release(&redacted_header);
                ret = 1;
        }
        return ret;