summaryrefslogtreecommitdiff
path: root/rpmio/rpmpgp.c
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2021-10-28 13:32:22 +0200
committerPanu Matilainen <pmatilai@redhat.com>2021-11-10 12:33:30 +0200
commit6e9531430d70fe80b67782ed57f1526aec9ed711 (patch)
treedd8f8c0a2a3cd58b4a84e67989822eb507115e4f /rpmio/rpmpgp.c
parenta1fac5beef99969f2a4ff28a8f916b30bdaea8b5 (diff)
downloadrpm-6e9531430d70fe80b67782ed57f1526aec9ed711.tar.gz
Fix hash context leak
The hash context is duplicated unconditionally, but there is an execution path exiting the function without it being finalized.
Diffstat (limited to 'rpmio/rpmpgp.c')
-rw-r--r--rpmio/rpmpgp.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index 861f6704c..1e4f66782 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -1310,6 +1310,7 @@ rpmRC pgpVerifySignature(pgpDigParams key, pgpDigParams sig, DIGEST_CTX hashctx)
}
rpmDigestFinal(ctx, (void **)&hash, &hashlen, 0);
+ ctx = NULL;
/* Compare leading 16 bits of digest for quick check. */
if (hash == NULL || memcmp(hash, sig->signhash16, 2) != 0)
@@ -1333,6 +1334,7 @@ rpmRC pgpVerifySignature(pgpDigParams key, pgpDigParams sig, DIGEST_CTX hashctx)
exit:
free(hash);
+ rpmDigestFinal(ctx, NULL, NULL, 0);
return res;
}