Blame SOURCES/0013-sysdb-make-sysdb_update_subdomains-more-robust.patch

8aada9
From 8ca799ea968e548337acb0300642a0d88f1bba9b Mon Sep 17 00:00:00 2001
8aada9
From: Sumit Bose <sbose@redhat.com>
8aada9
Date: Thu, 7 May 2020 15:47:35 +0200
8aada9
Subject: [PATCH 13/19] sysdb: make sysdb_update_subdomains() more robust
8aada9
MIME-Version: 1.0
8aada9
Content-Type: text/plain; charset=UTF-8
8aada9
Content-Transfer-Encoding: 8bit
8aada9
8aada9
Some NULL checks are added basically to allow that missing values can be
8aada9
set later.
8aada9
8aada9
Resolves: https://github.com/SSSD/sssd/issues/5151
8aada9
8aada9
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
8aada9
---
8aada9
 src/db/sysdb_subdomains.c | 12 +++++++++---
8aada9
 1 file changed, 9 insertions(+), 3 deletions(-)
8aada9
8aada9
diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c
8aada9
index b170d1978..d256817a6 100644
8aada9
--- a/src/db/sysdb_subdomains.c
8aada9
+++ b/src/db/sysdb_subdomains.c
8aada9
@@ -421,7 +421,9 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain,
8aada9
                 }
8aada9
 
8aada9
                 /* in theory these may change, but it should never happen */
8aada9
-                if (strcasecmp(dom->realm, realm) != 0) {
8aada9
+                if ((dom->realm == NULL && realm != NULL)
8aada9
+                        || (dom->realm != NULL && realm != NULL
8aada9
+                            && strcasecmp(dom->realm, realm) != 0)) {
8aada9
                     DEBUG(SSSDBG_TRACE_INTERNAL,
8aada9
                           "Realm name changed from [%s] to [%s]!\n",
8aada9
                            dom->realm, realm);
8aada9
@@ -432,7 +434,9 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain,
8aada9
                         goto done;
8aada9
                     }
8aada9
                 }
8aada9
-                if (strcasecmp(dom->flat_name, flat) != 0) {
8aada9
+                if ((dom->flat_name == NULL && flat != NULL)
8aada9
+                        || (dom->flat_name != NULL && flat != NULL
8aada9
+                            && strcasecmp(dom->flat_name, flat) != 0)) {
8aada9
                     DEBUG(SSSDBG_TRACE_INTERNAL,
8aada9
                           "Flat name changed from [%s] to [%s]!\n",
8aada9
                            dom->flat_name, flat);
8aada9
@@ -443,7 +447,9 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain,
8aada9
                         goto done;
8aada9
                     }
8aada9
                 }
8aada9
-                if (strcasecmp(dom->domain_id, id) != 0) {
8aada9
+                if ((dom->domain_id == NULL && id != NULL)
8aada9
+                        || (dom->domain_id != NULL && id != NULL
8aada9
+                            && strcasecmp(dom->domain_id, id) != 0)) {
8aada9
                     DEBUG(SSSDBG_TRACE_INTERNAL,
8aada9
                           "Domain changed from [%s] to [%s]!\n",
8aada9
                            dom->domain_id, id);
8aada9
-- 
8aada9
2.21.3
8aada9