[PATCH] Some Coverity findings

Volker Lendecke Volker.Lendecke at SerNet.DE
Wed Jun 13 06:41:52 UTC 2018


Hi!

Review appreciated!

Thanks, Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 70fa65c42fb39ed20b6ddf7279d031c6c2d42cc0 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 12 Jun 2018 21:09:40 +0200
Subject: [PATCH 1/6] dsdb: Fix CID 1436920 Unchecked return value

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/dsdb/samdb/ldb_modules/audit_log.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/source4/dsdb/samdb/ldb_modules/audit_log.c b/source4/dsdb/samdb/ldb_modules/audit_log.c
index fd2387699d3..23b4651b32d 100644
--- a/source4/dsdb/samdb/ldb_modules/audit_log.c
+++ b/source4/dsdb/samdb/ldb_modules/audit_log.c
@@ -1172,6 +1172,7 @@ static int add_transaction_id(
 		talloc_get_type(ldb_module_get_private(module),
 				struct audit_context);
 	struct dsdb_control_transaction_identifier *transaction_id;
+	int ret;
 
 	transaction_id = talloc_zero(
 		req,
@@ -1181,11 +1182,11 @@ static int add_transaction_id(
 		return ldb_oom(ldb);
 	}
 	transaction_id->transaction_guid = ac->transaction_guid;
-	ldb_request_add_control(req,
-				DSDB_CONTROL_TRANSACTION_IDENTIFIER_OID,
-				false,
-				transaction_id);
-	return LDB_SUCCESS;
+	ret = ldb_request_add_control(req,
+				      DSDB_CONTROL_TRANSACTION_IDENTIFIER_OID,
+				      false,
+				      transaction_id);
+	return ret;
 
 }
 
-- 
2.11.0


From 0becf2358f552c59215dc07ded6e1f4fc202fa5b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 12 Jun 2018 21:12:47 +0200
Subject: [PATCH 2/6] dsdb: Fix CID 1436919 Unchecked return value

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c b/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c
index 3e57af11a82..567c5b345d8 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c
+++ b/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c
@@ -194,6 +194,7 @@ static void test_get_password_action(void **state)
 	struct ldb_request *req = NULL;
 	struct ldb_reply *reply = NULL;
 	struct dsdb_control_password_acl_validation *pav = NULL;
+	int ret;
 
 	TALLOC_CTX *ctx = talloc_new(NULL);
 	ldb = ldb_init(ctx, NULL);
@@ -219,7 +220,8 @@ static void test_get_password_action(void **state)
 	/*
 	 * dsdb_control_password_acl_validation reset = false, expect "Change"
 	 */
-	ldb_build_mod_req(&req, ldb, ctx, NULL, NULL, NULL, NULL, NULL);
+	ret = ldb_build_mod_req(&req, ldb, ctx, NULL, NULL, NULL, NULL, NULL);
+	assert_int_equal(ret, LDB_SUCCESS);
 	reply = talloc_zero(ctx, struct ldb_reply);
 	pav = talloc_zero(req, struct dsdb_control_password_acl_validation);
 
-- 
2.11.0


From 1b49de42c38669833c7c2684d5f40025790b44de Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 12 Jun 2018 21:15:55 +0200
Subject: [PATCH 3/6] dsdb: Fix CID 1436918 Unchecked return value

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c b/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c
index 26392b78362..2c32b658a21 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c
+++ b/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c
@@ -189,11 +189,13 @@ static void add_session_data(
 	struct security_token *token = NULL;
 	struct dom_sid *sid = NULL;
 	struct GUID session_id;
+	bool ok;
 
 	sess = talloc_zero(ctx, struct auth_session_info);
 	token = talloc_zero(ctx, struct security_token);
 	sid = talloc_zero(ctx, struct dom_sid);
-	string_to_sid(sid, user_sid);
+	ok = string_to_sid(sid, user_sid);
+	assert_true(ok);
 	token->sids = sid;
 	sess->security_token = token;
 	GUID_from_string(session, &session_id);
-- 
2.11.0


From 74c28f51cd4f39cfb21a95c788b02283bdb26b16 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 12 Jun 2018 21:18:18 +0200
Subject: [PATCH 4/6] dsdb: Fix typos

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/dsdb/samdb/ldb_modules/partition.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index 6867cd7ef56..81df7053098 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -405,7 +405,7 @@ struct partition_copy_context {
  * A special DN has been updated in the primary partition. Now propagate those
  * changes to the remaining partitions.
  *
- * Note: that the operations are asyncchonous and this fuction is called
+ * Note: that the operations are asynchronous and this function is called
  *       from partition_copy_all_callback_handler in response to an async
  *       callback.
  */
@@ -671,7 +671,7 @@ static int partition_copy_all(
 		ldb_debug(
 			ldb,
 			LDB_DEBUG_ERROR,
-			"Unexpected opertation type (%d)\n", req->operation);
+			"Unexpected operation type (%d)\n", req->operation);
 		ret = LDB_ERR_OPERATIONS_ERROR;
 		break;
 	}
-- 
2.11.0


From 739464098a4339cb65c059245bb4d3a339115095 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 12 Jun 2018 21:22:10 +0200
Subject: [PATCH 5/6] dsdb: Fix CID 1435966 Unchecked return value

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/dsdb/samdb/ldb_modules/partition.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index 81df7053098..098fdb0916e 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -504,10 +504,14 @@ static int partition_copy_all_callback_action(
 								 req_msg->elements[el_idx].name) != NULL) {
 						continue;
 					}
-					ldb_msg_add_empty(modify_msg,
-							  req_msg->elements[el_idx].name,
-							  LDB_FLAG_MOD_REPLACE,
-							  NULL);
+					pret = ldb_msg_add_empty(
+						modify_msg,
+						req_msg->elements[el_idx].name,
+						LDB_FLAG_MOD_REPLACE,
+						NULL);
+					if (pret != LDB_SUCCESS) {
+						return pret;
+					}
 				}
 			}
 		}
-- 
2.11.0


From 957c4eb5ce4e0c1132162aaed627df76f29b18f8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 12 Jun 2018 21:31:15 +0200
Subject: [PATCH 6/6] dsdb: Fix CID 1435968 Dereference before null check

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/dsdb/samdb/ldb_modules/partition.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index 098fdb0916e..49bdeb04fa5 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -547,7 +547,6 @@ static int partition_copy_all_callback_handler(
 	struct ldb_reply *ares)
 {
 	struct partition_copy_context *ac = NULL;
-	int error = ares->error;
 
 	ac = talloc_get_type(
 		req->context,
@@ -574,8 +573,8 @@ static int partition_copy_all_callback_handler(
 			ac->request,
 			ares->referral);
 
-	case LDB_REPLY_DONE:
-		error = ares->error;
+	case LDB_REPLY_DONE: {
+		int error = ares->error;
 		if (error == LDB_SUCCESS) {
 			error = partition_copy_all_callback_action(
 				ac->module,
@@ -588,6 +587,7 @@ static int partition_copy_all_callback_handler(
 			ares->controls,
 			ares->response,
 			error);
+	}
 
 	default:
 		/* Can't happen */
-- 
2.11.0



More information about the samba-technical mailing list