]> git.ipfire.org Git - thirdparty/git.git/commit
send-pack: fix leaking push cert nonce
authorPatrick Steinhardt <ps@pks.im>
Thu, 5 Sep 2024 10:09:04 +0000 (12:09 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Sep 2024 15:49:11 +0000 (08:49 -0700)
commit49d47eb5416d22f185877a57380a1ffc28f172e1
treedf343a69aee235de263645f3789b11b01e669a74
parent42c153e1c06fcfea8446f11bf3fc3bcf9ea25867
send-pack: fix leaking push cert nonce

When retrieving the push cert nonce from the server, we first store the
constant returned by `server_feature_value()` and then, if the nonce is
valid, we duplicate the nonce memory to a NUL-terminated string, so that
we can pass it to `generate_push_cert()`. We never free the latter and
thus cause a memory leak.

Fix this by storing the limited-lifetime nonce into a scope-local
variable such that the long-lived, allocated nonce can be easily freed
without having to cast away its constness.

This leak was exposed by t5534, but fixing it is not sufficient to make
the whole test suite leak free.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
send-pack.c