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

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