[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Sat Feb 20 13:35:39 MST 2010


The branch, master has been updated
       via  77dd1b2... s3: Make string_to_sid survive the LOCAL-string_to_sid test
       via  e38908e... s3: Rename LOCAL-dom_sid_parse to LOCAL-string_to_sid, add some tests
       via  1e8a84a... s3: Add printf why LOCAL-dom_sid_parse failed
      from  2beaa19... s3: Slightly simplify the logic of completion_remote_filter

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 77dd1b29bb34500c5643670dcca6094ab526ce44
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Feb 20 21:32:07 2010 +0100

    s3: Make string_to_sid survive the LOCAL-string_to_sid test

commit e38908ea65966387076b59352fd1ac6bccf13e33
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Feb 20 21:31:16 2010 +0100

    s3: Rename LOCAL-dom_sid_parse to LOCAL-string_to_sid, add some tests

commit 1e8a84aac73f02ac6eec53b5a13ec31347070210
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Feb 20 21:07:08 2010 +0100

    s3: Add printf why LOCAL-dom_sid_parse failed

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/util_sid.c                     |   53 +++++++++++++++++++++-------
 source3/script/tests/test_smbtorture_s3.sh |    2 +-
 source3/torture/torture.c                  |   27 +++++++++++---
 3 files changed, 62 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c
index 20c2663..7d5dc1b 100644
--- a/source3/lib/util_sid.c
+++ b/source3/lib/util_sid.c
@@ -225,27 +225,33 @@ bool string_to_sid(DOM_SID *sidout, const char *sidstr)
 	uint32 conv;
 
 	if ((sidstr[0] != 'S' && sidstr[0] != 's') || sidstr[1] != '-') {
-		DEBUG(3,("string_to_sid: Sid %s does not start with 'S-'.\n", sidstr));
-		return False;
+		goto format_error;
 	}
 
 	ZERO_STRUCTP(sidout);
 
 	/* Get the revision number. */
 	p = sidstr + 2;
+
+	if (!isdigit(*p)) {
+		goto format_error;
+	}
+
 	conv = (uint32) strtoul(p, &q, 10);
 	if (!q || (*q != '-')) {
-		DEBUG(3,("string_to_sid: Sid %s is not in a valid format.\n", sidstr));
-		return False;
+		goto format_error;
 	}
 	sidout->sid_rev_num = (uint8) conv;
 	q++;
 
+	if (!isdigit(*q)) {
+		goto format_error;
+	}
+
 	/* get identauth */
 	conv = (uint32) strtoul(q, &q, 10);
 	if (!q || (*q != '-')) {
-		DEBUG(0,("string_to_sid: Sid %s is not in a valid format.\n", sidstr));
-		return False;
+		goto format_error;
 	}
 	/* identauth in decimal should be <  2^32 */
 	/* NOTE - the conv value is in big-endian format. */
@@ -259,16 +265,37 @@ bool string_to_sid(DOM_SID *sidout, const char *sidstr)
 	q++;
 	sidout->num_auths = 0;
 
-	for(conv = (uint32) strtoul(q, &q, 10);
-	    q && (*q =='-' || *q =='\0') && (sidout->num_auths < MAXSUBAUTHS);
-	    conv = (uint32) strtoul(q, &q, 10)) {
-		sid_append_rid(sidout, conv);
-		if (*q == '\0')
+	while (true) {
+		char *end;
+
+		if (!isdigit(*q)) {
+			goto format_error;
+		}
+
+		conv = strtoul(q, &end, 10);
+		if (end == q) {
+			goto format_error;
+		}
+
+		if (!sid_append_rid(sidout, conv)) {
+			DEBUG(3, ("Too many sid auths in %s\n", sidstr));
+			return false;
+		}
+
+		q = end;
+		if (*q == '\0') {
 			break;
-		q++;
+		}
+		if (*q != '-') {
+			goto format_error;
+		}
+		q += 1;
 	}
+	return true;
 
-	return True;
+format_error:
+	DEBUG(3, ("string_to_sid: SID %s is not in a valid format\n", sidstr));
+	return false;
 }
 
 /*****************************************************************
diff --git a/source3/script/tests/test_smbtorture_s3.sh b/source3/script/tests/test_smbtorture_s3.sh
index 3e0e3de..851e58a 100755
--- a/source3/script/tests/test_smbtorture_s3.sh
+++ b/source3/script/tests/test_smbtorture_s3.sh
@@ -33,7 +33,7 @@ tests="$tests OPEN XCOPY RENAME DELETE PROPERTIES W2K"
 tests="$tests TCON2 IOCTL CHKPATH FDSESS LOCAL-SUBSTITUTE CHAIN1"
 tests="$tests GETADDRINFO POSIX UID-REGRESSION-TEST SHORTNAME-TEST"
 tests="$tests LOCAL-BASE64 LOCAL-GENCACHE POSIX-APPEND"
-tests="$tests LOCAL-dom_sid_parse"
+tests="$tests LOCAL-string_to_sid"
 
 skipped1="RANDOMIPC NEGNOWAIT NBENCH ERRMAPEXTRACT TRANS2SCAN NTTRANSSCAN"
 skipped2="DENY1 DENY2 OPENATTR CASETABLE EATEST"
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index ae17173..24aea3c 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -6757,19 +6757,34 @@ static bool run_local_talloc_dict(int dummy)
 	return true;
 }
 
-static bool run_local_dom_sid_parse(int dummy) {
+static bool run_local_string_to_sid(int dummy) {
 	struct dom_sid sid;
 
-	if (dom_sid_parse("S--1-5-32-545", &sid)) {
+	if (string_to_sid(&sid, "S--1-5-32-545")) {
+		printf("allowing S--1-5-32-545\n");
 		return false;
 	}
-	if (dom_sid_parse("S-1-5-32-+545", &sid)) {
+	if (string_to_sid(&sid, "S-1-5-32-+545")) {
+		printf("allowing S-1-5-32-+545\n");
 		return false;
 	}
-	if (dom_sid_parse("S-1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0", &sid)) {
+	if (string_to_sid(&sid, "S-1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0")) {
+		printf("allowing S-1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0\n");
+		return false;
+	}
+	if (string_to_sid(&sid, "S-1-5-32-545-abc")) {
+		printf("allowing S-1-5-32-545-abc\n");
+		return false;
+	}
+	if (!string_to_sid(&sid, "S-1-5-32-545")) {
+		printf("could not parse S-1-5-32-545\n");
+		return false;
+	}
+	if (!sid_equal(&sid, &global_sid_Builtin_Users)) {
+		printf("mis-parsed S-1-5-32-545 as %s\n",
+		       sid_string_tos(&sid));
 		return false;
 	}
-
 	return true;
 }
 
@@ -7461,7 +7476,7 @@ static struct {
 	{ "LOCAL-MEMCACHE", run_local_memcache, 0},
 	{ "LOCAL-STREAM-NAME", run_local_stream_name, 0},
 	{ "LOCAL-WBCLIENT", run_local_wbclient, 0},
-	{ "LOCAL-dom_sid_parse", run_local_dom_sid_parse, 0},
+	{ "LOCAL-string_to_sid", run_local_string_to_sid, 0},
 	{ "LOCAL-DBTRANS", run_local_dbtrans, 0},
 	{NULL, NULL, 0}};
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list