]> git.ipfire.org Git - thirdparty/git.git/commit - gpg-interface.c
verify_signed_buffer: use tempfile object
authorJeff King <peff@peff.net>
Fri, 17 Jun 2016 23:38:43 +0000 (19:38 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sat, 18 Jun 2016 00:03:56 +0000 (17:03 -0700)
commit4322353bfb53a83e6657af50603d3521ee9d7d0c
treeddfc44a7a1f337a93237d434473cc8b52b3effff
parentc752fcc8e0df02c6b1bd4daec1d08f0f2bcca58a
verify_signed_buffer: use tempfile object

We use git_mkstemp to create a temporary file, and try to
clean it up in all exit paths from the function. But that
misses any cases where we die by signal, or by calling die()
in a sub-function. In addition, we missed one of the exit
paths.

Let's convert to using a tempfile object, which handles the
hard cases for us, and add the missing cleanup call. Note
that we would not simply want to rely on program exit to
catch our missed cleanup, as this function may be called
many times in a single program (for the same reason, we use
a static tempfile instead of heap-allocating a new one; that
gives an upper bound on our memory usage).

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