Blob Blame History Raw
From e660bc0594b6ddca143b460bb7edbbfba69f84ed Mon Sep 17 00:00:00 2001
From: Robbie Harwood <rharwood@redhat.com>
Date: Wed, 1 May 2019 11:27:13 -0400
Subject: [PATCH] Avoid uninitialized free when allocating buffers

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Reviewed-by: Simo Sorce <simo@redhat.com>
Resolves: #248
(cherry picked from commit eafa3c9272c95646400123f8e4d6fb50cf36d36c)
(cherry picked from commit e19466d172e0fd6d86b98b1423e9d99e0be30313)
[rharwood@redhat.com: fuzz around padded]
(cherry picked from commit abcc6cc90c6da5ea4fce65dd60e46b76767be557)
[rharwood@redhat.com: more padded fuzz]
---
 proxy/src/gp_export.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/proxy/src/gp_export.c b/proxy/src/gp_export.c
index dbfddeb..a5681c0 100644
--- a/proxy/src/gp_export.c
+++ b/proxy/src/gp_export.c
@@ -300,6 +300,7 @@ static int gp_encrypt_buffer(krb5_context context, krb5_keyblock *key,
                          &data_in,
                          &enc_handle);
     if (ret) {
+        free(enc_handle.ciphertext.data);
         ret = EINVAL;
         goto done;
     }
@@ -308,12 +309,12 @@ static int gp_encrypt_buffer(krb5_context context, krb5_keyblock *key,
                                enc_handle.ciphertext.data,
                                out);
     if (ret) {
+        free(enc_handle.ciphertext.data);
         goto done;
     }
 
 done:
     free(padded);
-    free(enc_handle.ciphertext.data);
     return ret;
 }