[PATCH] Make dom_sid_parse_endp always fill in "endp"

Volker Lendecke vl at samba.org
Mon Dec 5 14:17:28 UTC 2016


Hi!

Attached find a cleanup for dom_sid_parse_endp and its users.

Review appreciated!

Thanks, Volker
-------------- next part --------------
>From f92c8f458596a39959649f15fe07d261353eda0a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 1 Dec 2016 16:11:38 +0000
Subject: [PATCH 1/4] idmap_autorid: Add a {} pair in an if-statement

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

diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index 20cd5b72a98..aa3095babb4 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -243,7 +243,7 @@ static NTSTATUS idmap_autorid_id_to_sid(struct autorid_global_config *cfg,
 		map->status = ID_UNKNOWN;
 		return NT_STATUS_OK;
 	}
-	if ((q != NULL) && (*q != '\0'))
+	if ((q != NULL) && (*q != '\0')) {
 		if (sscanf(q+1, "%"SCNu32, &domain_range_index) != 1) {
 			DEBUG(10, ("Domain range index not found, "
 				   "ignoring mapping request\n"));
@@ -251,6 +251,7 @@ static NTSTATUS idmap_autorid_id_to_sid(struct autorid_global_config *cfg,
 			map->status = ID_UNKNOWN;
 			return NT_STATUS_OK;
 		}
+	}
 
 	TALLOC_FREE(data.dptr);
 
-- 
2.11.0


>From 4005b63622f3383d8adc282b934d527105ba0dd9 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 1 Dec 2016 16:15:29 +0000
Subject: [PATCH 2/4] lib: Make dom_sid_parse_endp init "endp" on all "ok"
 paths

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

diff --git a/libcli/security/dom_sid.c b/libcli/security/dom_sid.c
index 8b30ee67eea..5454c514c94 100644
--- a/libcli/security/dom_sid.c
+++ b/libcli/security/dom_sid.c
@@ -172,7 +172,7 @@ bool dom_sid_parse_endp(const char *sidstr,struct dom_sid *sidout,
 	sidout->num_auths = 0;
 	if (*q != '-') {
 		/* Just id_auth, no subauths */
-		return true;
+		goto done;
 	}
 
 	q++;
@@ -200,6 +200,7 @@ bool dom_sid_parse_endp(const char *sidstr,struct dom_sid *sidout,
 		}
 		q += 1;
 	}
+done:
 	if (endp != NULL) {
 		*endp = q;
 	}
-- 
2.11.0


>From 128bfb57ebb5483101f8840357c8d49dd6462b71 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 1 Dec 2016 16:16:14 +0000
Subject: [PATCH 3/4] idmap_autorid: dom_sid_parse_endp always initializes
 "endp" when ok

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/winbindd/idmap_autorid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index aa3095babb4..1fd6a760710 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -243,7 +243,7 @@ static NTSTATUS idmap_autorid_id_to_sid(struct autorid_global_config *cfg,
 		map->status = ID_UNKNOWN;
 		return NT_STATUS_OK;
 	}
-	if ((q != NULL) && (*q != '\0')) {
+	if (*q != '\0') {
 		if (sscanf(q+1, "%"SCNu32, &domain_range_index) != 1) {
 			DEBUG(10, ("Domain range index not found, "
 				   "ignoring mapping request\n"));
-- 
2.11.0


>From 83bc582b6cbb60e4f4636e92f528e86ed14570f1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 1 Dec 2016 16:16:14 +0000
Subject: [PATCH 4/4] winbind: dom_sid_parse_endp always initializes "endp"
 when ok

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/winbindd/winbindd_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c
index a35b59e5fb8..38e4b8b8edb 100644
--- a/source3/winbindd/winbindd_util.c
+++ b/source3/winbindd/winbindd_util.c
@@ -1651,7 +1651,7 @@ bool parse_sidlist(TALLOC_CTX *mem_ctx, const char *sidstr,
 			DEBUG(1, ("Could not parse sid %s\n", p));
 			return false;
 		}
-		if ((q == NULL) || (q[0] != '\n')) {
+		if (q[0] != '\n') {
 			DEBUG(1, ("Got invalid sidstr: %s\n", p));
 			return false;
 		}
-- 
2.11.0



More information about the samba-technical mailing list