Blame SOURCES/Always-free-ciphertext-data-in-gp_encrypt_buffer.patch

aa181f
From ccac7b766cd871aa0baeaebd697b386a47c28812 Mon Sep 17 00:00:00 2001
aa181f
From: Simo Sorce <simo@redhat.com>
aa181f
Date: Thu, 27 Aug 2020 15:35:40 -0400
aa181f
Subject: [PATCH] Always free ciphertext data in gp_encrypt_buffer
aa181f
aa181f
Signed-off-by: Simo Sorce <simo@redhat.com>
aa181f
[rharwood@redhat.com: rewrote commit message]
aa181f
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
aa181f
(cherry picked from commit fe9e3c29caab90daf19028fb31ff28622d8708a9)
aa181f
(cherry picked from commit d9a37354c9a040b151fbd737b84b7cacb315ec9d)
aa181f
---
aa181f
 src/gp_export.c | 7 +++----
aa181f
 1 file changed, 3 insertions(+), 4 deletions(-)
aa181f
aa181f
diff --git a/src/gp_export.c b/src/gp_export.c
aa181f
index a5681c0..fb2f81b 100644
aa181f
--- a/src/gp_export.c
aa181f
+++ b/src/gp_export.c
aa181f
@@ -308,10 +308,9 @@ static int gp_encrypt_buffer(krb5_context context, krb5_keyblock *key,
aa181f
     ret = gp_conv_octet_string(enc_handle.ciphertext.length,
aa181f
                                enc_handle.ciphertext.data,
aa181f
                                out);
aa181f
-    if (ret) {
aa181f
-        free(enc_handle.ciphertext.data);
aa181f
-        goto done;
aa181f
-    }
aa181f
+    /* the conversion function copies the data, so free our copy
aa181f
+     * unconditionally, or we leak */
aa181f
+    free(enc_handle.ciphertext.data);
aa181f
 
aa181f
 done:
aa181f
     free(padded);