[PATCH] Fix two CIDs and a few trivial ones

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Aug 21 19:46:01 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

Meet us at Storage Developer Conference (SDC)
Santa Clara, CA USA, September 24th-27th 2018
-------------- next part --------------
From ad7ba19c39bb82668ad5f321e9ebbc75d38a355f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 21 Aug 2018 21:38:01 +0200
Subject: [PATCH 1/5] libgpo: Fix CID 1438462 Error handling issues
 (CHECKED_RETURN)

Yes, this creates a leak of "data", but the other error exits in this
function are the same.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/libgpo/gpext/registry.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/source3/libgpo/gpext/registry.c b/source3/libgpo/gpext/registry.c
index 525493fcb2c..ffa1d020fb6 100644
--- a/source3/libgpo/gpext/registry.c
+++ b/source3/libgpo/gpext/registry.c
@@ -111,6 +111,7 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
 	struct registry_value *data = NULL;
 	struct gp_registry_entry *entry = NULL;
 	enum gp_reg_action action = GP_REG_ACTION_NONE;
+	enum ndr_err_code ndr_err;
 
 	ZERO_STRUCTP(*reg_entry);
 
@@ -120,8 +121,17 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
 
 	data->type = r->type;
 
-	ndr_push_union_blob(&data->data, mem_ctx, &r->data, r->type,
-			    (ndr_push_flags_fn_t)ndr_push_winreg_Data);
+	ndr_err = ndr_push_union_blob(
+		&data->data,
+		mem_ctx,
+		&r->data,
+		r->type,
+		(ndr_push_flags_fn_t)ndr_push_winreg_Data);
+	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		DBG_WARNING("ndr_push_winreg_Data failed: %s\n",
+			    ndr_errstr(ndr_err));
+		return false;
+	}
 
 	entry = talloc_zero(mem_ctx, struct gp_registry_entry);
 	if (!entry)
-- 
2.11.0


From 57be898fa2fe37ad9886c803f25e9144b4bca528 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 21 Aug 2018 21:41:05 +0200
Subject: [PATCH 2/5] dsdb: Fix CID 1438461 Error handling issues
 (CHECKED_RETURN)

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

diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index c4a41a28d04..584fd2185a2 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -4685,6 +4685,7 @@ static int replmd_make_prefix_child_dn(TALLOC_CTX *tmp_ctx,
 {
 	struct ldb_val deleted_child_rdn_val;
 	struct GUID_txt_buf guid_str;
+	int ret;
 	bool retb;
 
 	GUID_buf_string(&guid, &guid_str);
@@ -4751,10 +4752,13 @@ static int replmd_make_prefix_child_dn(TALLOC_CTX *tmp_ctx,
 	       sizeof(guid_str.buf));
 
 	/* Now set the value into the RDN, without parsing it */
-	ldb_dn_set_component(dn, 0, rdn_name,
-			     deleted_child_rdn_val);
+	ret = ldb_dn_set_component(
+		dn,
+		0,
+		rdn_name,
+		deleted_child_rdn_val);
 
-	return LDB_SUCCESS;
+	return ret;
 }
 
 
-- 
2.11.0


From df0ecc727ac750426c5c033bdefa35d1cb76bbe1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 21 Aug 2018 21:11:43 +0200
Subject: [PATCH 3/5] dsdb: Fix a typo

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/dsdb/repl/replicated_objects.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/source4/dsdb/repl/replicated_objects.c b/source4/dsdb/repl/replicated_objects.c
index fd7491d477f..fd567e9395c 100644
--- a/source4/dsdb/repl/replicated_objects.c
+++ b/source4/dsdb/repl/replicated_objects.c
@@ -607,8 +607,9 @@ WERROR dsdb_convert_object_ex(struct ldb_context *ldb,
 		}
 	} else {
 		if (!(instanceType & INSTANCE_TYPE_WRITE)) {
-			DEBUG(0, ("Refusing to replicate %s from a read-only repilca into a read-write replica!\n",
-				  ldb_dn_get_linearized(msg->dn)));
+			DBG_ERR("Refusing to replicate %s from a read-only "
+				"replica into a read-write replica!\n",
+				ldb_dn_get_linearized(msg->dn));
 			return WERR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA;
 		}
 	}
-- 
2.11.0


From 79cfe04277a90218cb2e87addab2d29ef193be1f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 21 Aug 2018 21:19:49 +0200
Subject: [PATCH 4/5] libads: Fix an error path talloc leak

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/libads/util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source3/libads/util.c b/source3/libads/util.c
index 68c7aede21e..f387ca60bf7 100644
--- a/source3/libads/util.c
+++ b/source3/libads/util.c
@@ -166,7 +166,8 @@ struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc)
 	result->serviceclass = talloc_strdup(result, srvprinc);
 	if (result->serviceclass == NULL) {
 		DBG_ERR("Out of memory\n");
-		return NULL;
+		TALLOC_FREE(result);
+		goto out;
 	}
 	result->port = -1;
 
-- 
2.11.0


From 335e6e49b1fb2a99d8d3372407c3b06c2690d36e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 21 Aug 2018 21:22:42 +0200
Subject: [PATCH 5/5] libads: Simplify parse_spn()

A few lines less and quite some bytes less .text

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/libads/util.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/source3/libads/util.c b/source3/libads/util.c
index f387ca60bf7..354125b74fe 100644
--- a/source3/libads/util.c
+++ b/source3/libads/util.c
@@ -166,8 +166,7 @@ struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc)
 	result->serviceclass = talloc_strdup(result, srvprinc);
 	if (result->serviceclass == NULL) {
 		DBG_ERR("Out of memory\n");
-		TALLOC_FREE(result);
-		goto out;
+		goto fail;
 	}
 	result->port = -1;
 
@@ -176,8 +175,7 @@ struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc)
 		/* illegal */
 		DBG_ERR("Failed to parse spn %s, no host definition\n",
 			srvprinc);
-		TALLOC_FREE(result);
-		goto out;
+		goto fail;
 	}
 
 	/* terminate service principal */
@@ -205,23 +203,20 @@ struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc)
 		/* illegal */
 		DBG_ERR("Failed to parse spn %s, illegal host definition\n",
 			srvprinc);
-		TALLOC_FREE(result);
-		goto out;
+		goto fail;
 	}
 	result->host = host_str;
 
 	if (result->servicename != NULL && (strlen(result->servicename) == 0)) {
 		DBG_ERR("Failed to parse spn %s, empty servicename "
 			"definition\n", srvprinc);
-		TALLOC_FREE(result);
-		goto out;
+		goto fail;
 	}
 	if (port_str != NULL) {
 		if (strlen(port_str) == 0) {
 			DBG_ERR("Failed to parse spn %s, empty port "
 				"definition\n", srvprinc);
-			TALLOC_FREE(result);
-			goto out;
+			goto fail;
 		}
 		result->port = (int32_t)strtol(port_str, NULL, 10);
 		if (result->port <= 0
@@ -230,10 +225,11 @@ struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc)
 			DBG_ERR("Failed to parse spn %s, port number "
 				"convertion failed\n", srvprinc);
 			errno = 0;
-			TALLOC_FREE(result);
-			goto out;
+			goto fail;
 		}
 	}
-out:
 	return result;
+fail:
+	TALLOC_FREE(result);
+	return NULL;
 }
-- 
2.11.0



More information about the samba-technical mailing list