Blame SOURCES/Fix-leak-in-KERB_AP_OPTIONS_CBT-server-support.patch

6cfd83
From 7a87189f7bdabc144e22d4caa6a0785a06416d8f Mon Sep 17 00:00:00 2001
0ba406
From: Greg Hudson <ghudson@mit.edu>
0ba406
Date: Fri, 24 Jul 2020 16:05:24 -0400
0ba406
Subject: [PATCH] Fix leak in KERB_AP_OPTIONS_CBT server support
0ba406
0ba406
In check_cbt(), use a local variable to hold the retrieved authdata
0ba406
list, and free it before returning.
0ba406
0ba406
ticket: 8900
0ba406
(cherry picked from commit bf2ddff13c178e0c291f8fb382b040080d159e4f)
0ba406
(cherry picked from commit 044e2209586fd1935d9a637df76d52f48c4f3e6e)
0ba406
---
0ba406
 src/lib/gssapi/krb5/accept_sec_context.c | 23 +++++++++++++----------
0ba406
 1 file changed, 13 insertions(+), 10 deletions(-)
0ba406
0ba406
diff --git a/src/lib/gssapi/krb5/accept_sec_context.c b/src/lib/gssapi/krb5/accept_sec_context.c
0ba406
index 175a24c4e..3d5b84b15 100644
0ba406
--- a/src/lib/gssapi/krb5/accept_sec_context.c
0ba406
+++ b/src/lib/gssapi/krb5/accept_sec_context.c
0ba406
@@ -433,27 +433,30 @@ static const uint8_t null_cb[CB_MD5_LEN];
0ba406
 /* Look for AP_OPTIONS in authdata.  If present and the options include
0ba406
  * KERB_AP_OPTIONS_CBT, set *cbt_out to true. */
0ba406
 static krb5_error_code
0ba406
-check_cbt(krb5_context context, krb5_authdata **authdata,
0ba406
+check_cbt(krb5_context context, krb5_authdata *const *authdata,
0ba406
           krb5_boolean *cbt_out)
0ba406
 {
0ba406
     krb5_error_code code;
0ba406
+    krb5_authdata **ad;
0ba406
     uint32_t ad_ap_options;
0ba406
     const uint32_t KERB_AP_OPTIONS_CBT = 0x4000;
0ba406
 
0ba406
     *cbt_out = FALSE;
0ba406
 
0ba406
     code = krb5_find_authdata(context, NULL, authdata,
0ba406
-                              KRB5_AUTHDATA_AP_OPTIONS, &authdata);
0ba406
-    if (code || authdata == NULL)
0ba406
+                              KRB5_AUTHDATA_AP_OPTIONS, &ad;;
0ba406
+    if (code || ad == NULL)
0ba406
         return code;
0ba406
-    if (authdata[1] != NULL || authdata[0]->length != 4)
0ba406
-        return KRB5KRB_AP_ERR_MSG_TYPE;
0ba406
+    if (ad[1] != NULL || ad[0]->length != 4) {
0ba406
+        code = KRB5KRB_AP_ERR_MSG_TYPE;
0ba406
+    } else {
0ba406
+        ad_ap_options = load_32_le(ad[0]->contents);
0ba406
+        if (ad_ap_options & KERB_AP_OPTIONS_CBT)
0ba406
+            *cbt_out = TRUE;
0ba406
+    }
0ba406
 
0ba406
-    ad_ap_options = load_32_le(authdata[0]->contents);
0ba406
-    if (ad_ap_options & KERB_AP_OPTIONS_CBT)
0ba406
-        *cbt_out = TRUE;
0ba406
-
0ba406
-    return 0;
0ba406
+    krb5_free_authdata(context, ad);
0ba406
+    return code;
0ba406
 }
0ba406
 
0ba406
 /*