aboutsummaryrefslogtreecommitdiffstats
path: root/gpg-interface.c
diff options
context:
space:
mode:
authorredoste <redoste@redoste.xyz>2025-07-07 20:48:51 +0200
committerJunio C Hamano <gitster@pobox.com>2025-07-07 13:41:25 -0700
commit4498127b04372cff39cf34c5559d1cf547c643e6 (patch)
tree2e7327ea664ad3b899dbe74a0955bfcf0ce2c99f /gpg-interface.c
parentGit 2.50 (diff)
downloadgit-4498127b04372cff39cf34c5559d1cf547c643e6.tar.gz
git-4498127b04372cff39cf34c5559d1cf547c643e6.zip
ssh signing: don't detach the filename strbuf from key_file tempfile
Detaching the filename string from the tempfile structure used to cause delete_tempfile() to fail and the temporary file was not cleaned up. While it's possible to get rid of the allocation and copy from xstrdup(), it keeps the code symetric with the other branch since interpolate_path() also allocates and ssh_signing_key_file is freed in both cases. The exisiting test was updated to check if the temporary files are properly deleted. To prevent TMPDIR from leaking into the other tests, a new subshell is created, however this prevents test_config from working. The cleanup of the config changed in the subshell is done by test_unconfig in a call to test_when_finished outside of it. Helped-by: brian m. carlson <sandals@crustytoothpaste.net> Helped-by: Patrick Steinhardt <ps@pks.im> Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: redoste <redoste@redoste.xyz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gpg-interface.c')
-rw-r--r--gpg-interface.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gpg-interface.c b/gpg-interface.c
index 0896458de5..bdcc8c2a2e 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -1048,7 +1048,7 @@ static int sign_buffer_ssh(struct strbuf *buffer, struct strbuf *signature,
key_file->filename.buf);
goto out;
}
- ssh_signing_key_file = strbuf_detach(&key_file->filename, NULL);
+ ssh_signing_key_file = xstrdup(key_file->filename.buf);
} else {
/* We assume a file */
ssh_signing_key_file = interpolate_path(signing_key, 1);