Blame SOURCES/Avoid-uninitialized-free-when-allocating-buffers.patch

cc8bf3
From e660bc0594b6ddca143b460bb7edbbfba69f84ed Mon Sep 17 00:00:00 2001
cc8bf3
From: Robbie Harwood <rharwood@redhat.com>
cc8bf3
Date: Wed, 1 May 2019 11:27:13 -0400
cc8bf3
Subject: [PATCH] Avoid uninitialized free when allocating buffers
cc8bf3
cc8bf3
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
cc8bf3
Reviewed-by: Simo Sorce <simo@redhat.com>
cc8bf3
Resolves: #248
cc8bf3
(cherry picked from commit eafa3c9272c95646400123f8e4d6fb50cf36d36c)
cc8bf3
(cherry picked from commit e19466d172e0fd6d86b98b1423e9d99e0be30313)
cc8bf3
[rharwood@redhat.com: fuzz around padded]
cc8bf3
(cherry picked from commit abcc6cc90c6da5ea4fce65dd60e46b76767be557)
cc8bf3
[rharwood@redhat.com: more padded fuzz]
cc8bf3
---
cc8bf3
 proxy/src/gp_export.c | 3 ++-
cc8bf3
 1 file changed, 2 insertions(+), 1 deletion(-)
cc8bf3
cc8bf3
diff --git a/proxy/src/gp_export.c b/proxy/src/gp_export.c
cc8bf3
index dbfddeb..a5681c0 100644
cc8bf3
--- a/proxy/src/gp_export.c
cc8bf3
+++ b/proxy/src/gp_export.c
cc8bf3
@@ -300,6 +300,7 @@ static int gp_encrypt_buffer(krb5_context context, krb5_keyblock *key,
cc8bf3
                          &data_in,
cc8bf3
                          &enc_handle);
cc8bf3
     if (ret) {
cc8bf3
+        free(enc_handle.ciphertext.data);
cc8bf3
         ret = EINVAL;
cc8bf3
         goto done;
cc8bf3
     }
cc8bf3
@@ -308,12 +309,12 @@ static int gp_encrypt_buffer(krb5_context context, krb5_keyblock *key,
cc8bf3
                                enc_handle.ciphertext.data,
cc8bf3
                                out);
cc8bf3
     if (ret) {
cc8bf3
+        free(enc_handle.ciphertext.data);
cc8bf3
         goto done;
cc8bf3
     }
cc8bf3
 
cc8bf3
 done:
cc8bf3
     free(padded);
cc8bf3
-    free(enc_handle.ciphertext.data);
cc8bf3
     return ret;
cc8bf3
 }
cc8bf3