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