summaryrefslogtreecommitdiff
path: root/gpg-interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'gpg-interface.c')
-rw-r--r--gpg-interface.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/gpg-interface.c b/gpg-interface.c
index 8b0e874..1ef73fb 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -7,6 +7,20 @@
static char *configured_signing_key;
static const char *gpg_program = "gpg";
+void signature_check_clear(struct signature_check *sigc)
+{
+ free(sigc->payload);
+ free(sigc->gpg_output);
+ free(sigc->gpg_status);
+ free(sigc->signer);
+ free(sigc->key);
+ sigc->payload = NULL;
+ sigc->gpg_output = NULL;
+ sigc->gpg_status = NULL;
+ sigc->signer = NULL;
+ sigc->key = NULL;
+}
+
void set_signing_key(const char *key)
{
free(configured_signing_key);
@@ -41,12 +55,11 @@ const char *get_signing_key(void)
*/
int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *signing_key)
{
- struct child_process gpg;
+ struct child_process gpg = CHILD_PROCESS_INIT;
const char *args[4];
ssize_t len;
size_t i, j, bottom;
- memset(&gpg, 0, sizeof(gpg));
gpg.argv = args;
gpg.in = -1;
gpg.out = -1;
@@ -102,7 +115,7 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
const char *signature, size_t signature_size,
struct strbuf *gpg_output, struct strbuf *gpg_status)
{
- struct child_process gpg;
+ struct child_process gpg = CHILD_PROCESS_INIT;
const char *args_gpg[] = {NULL, "--status-fd=1", "--verify", "FILE", "-", NULL};
char path[PATH_MAX];
int fd, ret;
@@ -119,7 +132,6 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
path, strerror(errno));
close(fd);
- memset(&gpg, 0, sizeof(gpg));
gpg.argv = args_gpg;
gpg.in = -1;
gpg.out = -1;