[SCM] Samba Shared Repository - branch v3-4-test updated - release-4-0-0alpha7-846-g5b9477f

Volker Lendecke vlendec at samba.org
Thu Apr 30 11:41:00 GMT 2009


The branch, v3-4-test has been updated
       via  5b9477f9930d0c6511c70409561c04c5729bcc05 (commit)
      from  b7c4a63d034f8c33b3a4857cae41270bd55e270f (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-test


- Log -----------------------------------------------------------------
commit 5b9477f9930d0c6511c70409561c04c5729bcc05
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Apr 30 13:37:19 2009 +0200

    Re-import the v3-3 version of str_list_make().
    
    The merged version behaves differently: "Domain Users" is parsed into two
    values, as it does not look at quotes. Samba3 users depend on the ability do
    say for example
    
    valid users = "domain users"
    
    which would not work anymore with the merged version.
    
    Thanks to Björn Jacke for testing this!
    
    Volker

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

Summary of changes:
 source3/lib/util_str.c |   66 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 59 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index b9ccb83..84e8219 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -2422,17 +2422,69 @@ char *escape_shell_string(const char *src)
 }
 
 /***************************************************
- Wrapper for str_list_make() to restore the s3 behavior.
- In samba 3.2 passing NULL or an empty string returned NULL.
-
- In master, it now returns a list of length 1 with the first string set
- to NULL (an empty list)
+ str_list_make, v3 version. The v4 version does not
+ look at quoted strings with embedded blanks, so
+ do NOT merge this function please!
 ***************************************************/
 
+#define S_LIST_ABS 16 /* List Allocation Block Size */
+
 char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
 {
-	if (!string || !*string) {
+	char **list;
+	const char *str;
+	char *s;
+	int num, lsize;
+	char *tok;
+
+	if (!string || !*string)
+		return NULL;
+
+	list = TALLOC_ARRAY(mem_ctx, char *, S_LIST_ABS+1);
+	if (list == NULL) {
+		return NULL;
+	}
+	lsize = S_LIST_ABS;
+
+	s = talloc_strdup(list, string);
+	if (s == NULL) {
+		DEBUG(0,("str_list_make: Unable to allocate memory"));
+		TALLOC_FREE(list);
 		return NULL;
 	}
-	return str_list_make(mem_ctx, string, sep);
+	if (!sep) sep = LIST_SEP;
+
+	num = 0;
+	str = s;
+
+	while (next_token_talloc(list, &str, &tok, sep)) {
+
+		if (num == lsize) {
+			char **tmp;
+
+			lsize += S_LIST_ABS;
+
+			tmp = TALLOC_REALLOC_ARRAY(mem_ctx, list, char *,
+						   lsize + 1);
+			if (tmp == NULL) {
+				DEBUG(0,("str_list_make: "
+					"Unable to allocate memory"));
+				TALLOC_FREE(list);
+				return NULL;
+			}
+
+			list = tmp;
+
+			memset (&list[num], 0,
+				((sizeof(char**)) * (S_LIST_ABS +1)));
+		}
+
+		list[num] = tok;
+		num += 1;
+	}
+
+	list[num] = NULL;
+
+	TALLOC_FREE(s);
+	return list;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list