summaryrefslogtreecommitdiff
path: root/backport-Fix-hash-context-leak.patch
blob: f8fda68ff9e7760e26997f4f8947a3e4de68d970 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 6e9531430d70fe80b67782ed57f1526aec9ed711 Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@sequoia-pgp.org>
Date: Thu, 28 Oct 2021 13:32:22 +0200
Subject: [PATCH] Fix hash context leak

The hash context is duplicated unconditionally, but there is an
execution path exiting the function without it being finalized.
---
 rpmio/rpmpgp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index 861f670..1e4f667 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;
 
 }
-- 
1.8.3.1