Blame SOURCES/bind-dyndb-ldap-tkrizek-0006-Coverity-fix-REVERSE_INULL-for-pevent-inst.patch

c96fbb
From 13b185182aeb48562cf63251b84bcf910b57a0fc Mon Sep 17 00:00:00 2001
c96fbb
From: Tomas Krizek <tkrizek@redhat.com>
c96fbb
Date: Mon, 27 Mar 2017 19:41:05 +0200
c96fbb
Subject: [PATCH] Coverity: fix REVERSE_INULL for pevent->inst
c96fbb
MIME-Version: 1.0
c96fbb
Content-Type: text/plain; charset=UTF-8
c96fbb
Content-Transfer-Encoding: 8bit
c96fbb
c96fbb
With the DynDB API changes, the ldap instance is acquired
c96fbb
differently. Previously, obtaining the instance could fail when
c96fbb
LDAP was disconnecting, thus the NULL check was necessary in the
c96fbb
cleanup part.
c96fbb
c96fbb
Now, inst is obtained directly from the API. I'm not sure what is
c96fbb
the exact behaviour in edge cases such as LDAP disconnecting, so
c96fbb
I perform the NULL check a bit earlier, just to be safe.
c96fbb
c96fbb
Reviewed-By: Petr Menšík <pemensik@redhat.com>
c96fbb
---
c96fbb
 src/ldap_helper.c | 43 ++++++++++++++++++++++---------------------
c96fbb
 1 file changed, 22 insertions(+), 21 deletions(-)
c96fbb
c96fbb
diff --git a/src/ldap_helper.c b/src/ldap_helper.c
c96fbb
index 1fa0ec9adfa2b9ca589587244da03cc6f0584919..9e0174a785d41e2a809130b348345870ca880978 100644
c96fbb
--- a/src/ldap_helper.c
c96fbb
+++ b/src/ldap_helper.c
c96fbb
@@ -3714,6 +3714,7 @@ update_zone(isc_task_t *task, isc_event_t *event)
c96fbb
 	mctx = pevent->mctx;
c96fbb
 	dns_name_init(&prevname, NULL);
c96fbb
 
c96fbb
+	REQUIRE(inst != NULL);
c96fbb
 	INSIST(task == inst->task); /* For task-exclusive mode */
c96fbb
 
c96fbb
 	if (SYNCREPL_DEL(pevent->chgtype)) {
c96fbb
@@ -3730,12 +3731,11 @@ update_zone(isc_task_t *task, isc_event_t *event)
c96fbb
 	}
c96fbb
 
c96fbb
 cleanup:
c96fbb
-	if (inst != NULL) {
c96fbb
-		sync_concurr_limit_signal(inst->sctx);
c96fbb
-		sync_event_signal(inst->sctx, pevent);
c96fbb
-		if (dns_name_dynamic(&prevname))
c96fbb
-			dns_name_free(&prevname, inst->mctx);
c96fbb
-	}
c96fbb
+	sync_concurr_limit_signal(inst->sctx);
c96fbb
+	sync_event_signal(inst->sctx, pevent);
c96fbb
+	if (dns_name_dynamic(&prevname))
c96fbb
+		dns_name_free(&prevname, inst->mctx);
c96fbb
+
c96fbb
 	if (result != ISC_R_SUCCESS)
c96fbb
 		log_error_r("update_zone (syncrepl) failed for %s. "
c96fbb
 			    "Zones can be outdated, run `rndc reload`",
c96fbb
@@ -3760,14 +3760,14 @@ update_config(isc_task_t * task, isc_event_t *event)
c96fbb
 
c96fbb
 	mctx = pevent->mctx;
c96fbb
 
c96fbb
+	REQUIRE(inst != NULL);
c96fbb
 	INSIST(task == inst->task); /* For task-exclusive mode */
c96fbb
 	CHECK(ldap_parse_configentry(entry, inst));
c96fbb
 
c96fbb
 cleanup:
c96fbb
-	if (inst != NULL) {
c96fbb
-		sync_concurr_limit_signal(inst->sctx);
c96fbb
-		sync_event_signal(inst->sctx, pevent);
c96fbb
-	}
c96fbb
+	sync_concurr_limit_signal(inst->sctx);
c96fbb
+	sync_event_signal(inst->sctx, pevent);
c96fbb
+
c96fbb
 	if (result != ISC_R_SUCCESS)
c96fbb
 		log_error_r("update_config (syncrepl) failed for %s. "
c96fbb
 			    "Configuration can be outdated, run `rndc reload`",
c96fbb
@@ -3790,14 +3790,14 @@ update_serverconfig(isc_task_t * task, isc_event_t *event)
c96fbb
 
c96fbb
 	mctx = pevent->mctx;
c96fbb
 
c96fbb
+	REQUIRE(inst != NULL);
c96fbb
 	INSIST(task == inst->task); /* For task-exclusive mode */
c96fbb
 	CHECK(ldap_parse_serverconfigentry(entry, inst));
c96fbb
 
c96fbb
 cleanup:
c96fbb
-	if (inst != NULL) {
c96fbb
-		sync_concurr_limit_signal(inst->sctx);
c96fbb
-		sync_event_signal(inst->sctx, pevent);
c96fbb
-	}
c96fbb
+	sync_concurr_limit_signal(inst->sctx);
c96fbb
+	sync_event_signal(inst->sctx, pevent);
c96fbb
+
c96fbb
 	if (result != ISC_R_SUCCESS)
c96fbb
 		log_error_r("update_serverconfig (syncrepl) failed for %s. "
c96fbb
 			    "Configuration can be outdated, run `rndc reload`",
c96fbb
@@ -3860,6 +3860,7 @@ update_record(isc_task_t *task, isc_event_t *event)
c96fbb
 	dns_name_init(&prevname, NULL);
c96fbb
 	dns_name_init(&prevorigin, NULL);
c96fbb
 
c96fbb
+	REQUIRE(inst != NULL);
c96fbb
 	CHECK(zr_get_zone_ptr(inst->zone_register, &entry->zone_name, &raw, &secure));
c96fbb
 	zone_found = ISC_TRUE;
c96fbb
 
c96fbb
@@ -4020,13 +4021,12 @@ cleanup:
c96fbb
 			    ldap_entry_logname(entry), pevent->chgtype);
c96fbb
 	}
c96fbb
 
c96fbb
-	if (inst != NULL) {
c96fbb
-		sync_concurr_limit_signal(inst->sctx);
c96fbb
-		if (dns_name_dynamic(&prevname))
c96fbb
-			dns_name_free(&prevname, inst->mctx);
c96fbb
-		if (dns_name_dynamic(&prevorigin))
c96fbb
-			dns_name_free(&prevorigin, inst->mctx);
c96fbb
-	}
c96fbb
+	sync_concurr_limit_signal(inst->sctx);
c96fbb
+	if (dns_name_dynamic(&prevname))
c96fbb
+		dns_name_free(&prevname, inst->mctx);
c96fbb
+	if (dns_name_dynamic(&prevorigin))
c96fbb
+		dns_name_free(&prevorigin, inst->mctx);
c96fbb
+
c96fbb
 	if (raw != NULL)
c96fbb
 		dns_zone_detach(&raw;;
c96fbb
 	if (secure != NULL)
c96fbb
@@ -4106,6 +4106,7 @@ syncrepl_update(ldap_instance_t *inst, ldap_entry_t **entryp, int chgtype)
c96fbb
 	isc_task_t *task = NULL;
c96fbb
 	isc_boolean_t synchronous;
c96fbb
 
c96fbb
+	REQUIRE(inst != NULL);
c96fbb
 	REQUIRE(entryp != NULL);
c96fbb
 	entry = *entryp;
c96fbb
 	REQUIRE(entry->class != LDAP_ENTRYCLASS_NONE);
c96fbb
-- 
c96fbb
2.9.3
c96fbb