afd354
From 3bac1a71756c634fe6b8cb3858ee9df87b1a660d Mon Sep 17 00:00:00 2001
afd354
From: Robbie Harwood <rharwood@redhat.com>
afd354
Date: Tue, 23 Aug 2016 16:47:00 -0400
afd354
Subject: [PATCH] krb5-1.12-api.patch
afd354
afd354
Reference docs don't define what happens if you call krb5_realm_compare() with
afd354
malformed krb5_principal structures.  Define a behavior which keeps it from
afd354
crashing if applications don't check ahead of time.
afd354
---
afd354
 src/lib/krb5/krb/princ_comp.c | 7 +++++++
afd354
 1 file changed, 7 insertions(+)
afd354
afd354
diff --git a/src/lib/krb5/krb/princ_comp.c b/src/lib/krb5/krb/princ_comp.c
afd354
index a6936107d..0ed78833b 100644
afd354
--- a/src/lib/krb5/krb/princ_comp.c
afd354
+++ b/src/lib/krb5/krb/princ_comp.c
afd354
@@ -36,6 +36,10 @@ realm_compare_flags(krb5_context context,
afd354
     const krb5_data *realm1 = &princ1->realm;
afd354
     const krb5_data *realm2 = &princ2->realm;
afd354
 
afd354
+    if (princ1 == NULL || princ2 == NULL)
afd354
+        return FALSE;
afd354
+    if (realm1 == NULL || realm2 == NULL)
afd354
+        return FALSE;
afd354
     if (realm1->length != realm2->length)
afd354
         return FALSE;
afd354
     if (realm1->length == 0)
afd354
@@ -88,6 +92,9 @@ krb5_principal_compare_flags(krb5_context context,
afd354
     krb5_principal upn2 = NULL;
afd354
     krb5_boolean ret = FALSE;
afd354
 
afd354
+    if (princ1 == NULL || princ2 == NULL)
afd354
+        return FALSE;
afd354
+
afd354
     if (flags & KRB5_PRINCIPAL_COMPARE_ENTERPRISE) {
afd354
         /* Treat UPNs as if they were real principals */
afd354
         if (princ1->type == KRB5_NT_ENTERPRISE_PRINCIPAL) {