[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-test-1620-gfd34ce4

Volker Lendecke vl at samba.org
Wed Jan 23 14:08:54 GMT 2008


The branch, v3-2-test has been updated
       via  fd34ce437057bb34cdc37f4b066e424000d36789 (commit)
      from  da131d089db98017632103aa9bbe38c98f7a3fc1 (commit)

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


- Log -----------------------------------------------------------------
commit fd34ce437057bb34cdc37f4b066e424000d36789
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Jan 23 11:04:10 2008 +0100

    strtok -> strtok_r

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

Summary of changes:
 source/client/client.c          |    5 +++--
 source/client/clitar.c          |    7 ++++---
 source/client/smbmnt.c          |    5 +++--
 source/client/smbmount.c        |    4 +++-
 source/lib/afs_settoken.c       |   29 +++++++++++++++--------------
 source/lib/debug.c              |    5 +++--
 source/libads/ads_struct.c      |    7 ++++---
 source/modules/vfs_recycle.c    |    4 +++-
 source/nmbd/nmbd_processlogon.c |    3 ++-
 source/param/loadparm.c         |    4 +++-
 source/printing/load.c          |    4 +++-
 source/printing/lpq_parse.c     |    6 ++++--
 source/printing/print_aix.c     |    3 ++-
 source/rpcclient/cmd_spoolss.c  |   10 ++++++----
 source/smbd/msdfs.c             |    5 +++--
 source/smbd/password.c          |   12 ++++++++----
 source/torture/torture.c        |    5 +++--
 source/web/cgi.c                |    4 +++-
 18 files changed, 75 insertions(+), 47 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/client/client.c b/source/client/client.c
index 28b4a2b..c934310 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -1463,6 +1463,7 @@ static int cmd_mkdir(void)
 		struct cli_state *targetcli;
 		char *targetname = NULL;
 		char *p = NULL;
+		char *saveptr;
 
 		ddir2 = talloc_strdup(ctx, "");
 		if (!ddir2) {
@@ -1478,7 +1479,7 @@ static int cmd_mkdir(void)
 			return 1;
 		}
 		trim_char(ddir,'.','\0');
-		p = strtok(ddir,"/\\");
+		p = strtok_r(ddir, "/\\", &saveptr);
 		while (p) {
 			ddir2 = talloc_asprintf_append(ddir2, p);
 			if (!ddir2) {
@@ -1491,7 +1492,7 @@ static int cmd_mkdir(void)
 			if (!ddir2) {
 				return 1;
 			}
-			p = strtok(NULL,"/\\");
+			p = strtok_r(NULL, "/\\", &saveptr);
 		}
 	} else {
 		do_mkdir(mask);
diff --git a/source/client/clitar.c b/source/client/clitar.c
index 135815c..816e7b1 100644
--- a/source/client/clitar.c
+++ b/source/client/clitar.c
@@ -513,6 +513,7 @@ static bool ensurepath(const char *fname)
 	char *partpath, *ffname;
 	const char *p=fname;
 	char *basehack;
+	char *saveptr;
 
 	DEBUG(5, ( "Ensurepath called with: %s\n", fname));
 
@@ -528,7 +529,7 @@ static bool ensurepath(const char *fname)
 
 	*partpath = 0;
 
-	/* fname copied to ffname so can strtok */
+	/* fname copied to ffname so can strtok_r */
 
 	safe_strcpy(ffname, fname, strlen(fname));
 
@@ -541,7 +542,7 @@ static bool ensurepath(const char *fname)
 		*basehack='\0';
 	}
 
-	p=strtok(ffname, "\\");
+	p=strtok_r(ffname, "\\", &saveptr);
 
 	while (p) {
 		safe_strcat(partpath, p, strlen(fname) + 1);
@@ -558,7 +559,7 @@ static bool ensurepath(const char *fname)
 		}
 
 		safe_strcat(partpath, "\\", strlen(fname) + 1);
-		p = strtok(NULL,"/\\");
+		p = strtok_r(NULL, "/\\", &saveptr);
 	}
 
 	SAFE_FREE(partpath);
diff --git a/source/client/smbmnt.c b/source/client/smbmnt.c
index 7f1e1d5..79c55b2 100644
--- a/source/client/smbmnt.c
+++ b/source/client/smbmnt.c
@@ -162,6 +162,7 @@ do_mount(char *share_name, unsigned int flags, struct smb_mount_data *data)
 	char *release, *major, *minor;
 	char *data1, *data2;
 	int ret;
+	char *saveptr;
 
 	if (asprintf(&opts,
 			"version=7,uid=%d,gid=%d,file_mode=0%o,dir_mode=0%o,%s",
@@ -172,8 +173,8 @@ do_mount(char *share_name, unsigned int flags, struct smb_mount_data *data)
 
 	uname(&uts);
 	release = uts.release;
-	major = strtok(release, ".");
-	minor = strtok(NULL, ".");
+	major = strtok_r(release, ".", &saveptr);
+	minor = strtok_r(NULL, ".", &saveptr);
 	if (major && minor && atoi(major) == 2 && atoi(minor) < 4) {
 		/* < 2.4, assume struct */
 		data1 = (char *) data;
diff --git a/source/client/smbmount.c b/source/client/smbmount.c
index 98c61a3..9fe2d36 100644
--- a/source/client/smbmount.c
+++ b/source/client/smbmount.c
@@ -764,6 +764,7 @@ static void parse_mount_smb(int argc, char **argv)
 	char *opts;
 	char *opteq;
 	int val;
+	char *saveptr;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	/* FIXME: This function can silently fail if the arguments are
@@ -813,7 +814,8 @@ static void parse_mount_smb(int argc, char **argv)
 	/*
 	 * option parsing from nfsmount.c (util-linux-2.9u)
 	 */
-        for (opts = strtok(optarg, ","); opts; opts = strtok(NULL, ",")) {
+        for (opts = strtok_r(optarg, ",", &saveptr); opts;
+	     opts = strtok_r(NULL, ",", &saveptr)) {
 		DEBUG(3, ("opts: %s\n", opts));
                 if ((opteq = strchr_m(opts, '='))) {
                         val = atoi(opteq + 1);
diff --git a/source/lib/afs_settoken.c b/source/lib/afs_settoken.c
index aeef1c3..444f09e 100644
--- a/source/lib/afs_settoken.c
+++ b/source/lib/afs_settoken.c
@@ -53,20 +53,21 @@ static bool afs_decode_token(const char *string, char **cell,
 {
 	DATA_BLOB blob;
 	struct ClearToken result_ct;
+	char *saveptr;
 
 	char *s = SMB_STRDUP(string);
 
 	char *t;
 
-	if ((t = strtok(s, "\n")) == NULL) {
-		DEBUG(10, ("strtok failed\n"));
+	if ((t = strtok_r(s, "\n", &saveptr)) == NULL) {
+		DEBUG(10, ("strtok_r failed\n"));
 		return False;
 	}
 
 	*cell = SMB_STRDUP(t);
 
-	if ((t = strtok(NULL, "\n")) == NULL) {
-		DEBUG(10, ("strtok failed\n"));
+	if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
+		DEBUG(10, ("strtok_r failed\n"));
 		return False;
 	}
 
@@ -75,8 +76,8 @@ static bool afs_decode_token(const char *string, char **cell,
 		return False;
 	}
 		
-	if ((t = strtok(NULL, "\n")) == NULL) {
-		DEBUG(10, ("strtok failed\n"));
+	if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
+		DEBUG(10, ("strtok_r failed\n"));
 		return False;
 	}
 
@@ -93,8 +94,8 @@ static bool afs_decode_token(const char *string, char **cell,
 
 	data_blob_free(&blob);
 
-	if ((t = strtok(NULL, "\n")) == NULL) {
-		DEBUG(10, ("strtok failed\n"));
+	if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
+		DEBUG(10, ("strtok_r failed\n"));
 		return False;
 	}
 
@@ -103,8 +104,8 @@ static bool afs_decode_token(const char *string, char **cell,
 		return False;
 	}
 		
-	if ((t = strtok(NULL, "\n")) == NULL) {
-		DEBUG(10, ("strtok failed\n"));
+	if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
+		DEBUG(10, ("strtok_r failed\n"));
 		return False;
 	}
 
@@ -113,8 +114,8 @@ static bool afs_decode_token(const char *string, char **cell,
 		return False;
 	}
 		
-	if ((t = strtok(NULL, "\n")) == NULL) {
-		DEBUG(10, ("strtok failed\n"));
+	if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
+		DEBUG(10, ("strtok_r failed\n"));
 		return False;
 	}
 
@@ -123,8 +124,8 @@ static bool afs_decode_token(const char *string, char **cell,
 		return False;
 	}
 		
-	if ((t = strtok(NULL, "\n")) == NULL) {
-		DEBUG(10, ("strtok failed\n"));
+	if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
+		DEBUG(10, ("strtok_r failed\n"));
 		return False;
 	}
 
diff --git a/source/lib/debug.c b/source/lib/debug.c
index 6c1bfea..51bb0d7 100644
--- a/source/lib/debug.c
+++ b/source/lib/debug.c
@@ -429,8 +429,9 @@ static bool debug_parse_params(char **params)
 
 	/* Fill in new debug class levels */
 	for (; i < debug_num_classes && params[i]; i++) {
-		if ((class_name=strtok(params[i],":")) &&
-			(class_level=strtok(NULL, "\0")) &&
+		char *saveptr;
+		if ((class_name = strtok_r(params[i],":", &saveptr)) &&
+			(class_level = strtok_r(NULL, "\0", &saveptr)) &&
             ((ndx = debug_lookup_classname(class_name)) != -1)) {
 				DEBUGLEVEL_CLASS[ndx] = atoi(class_level);
 				DEBUGLEVEL_CLASS_ISSET[ndx] = True;
diff --git a/source/libads/ads_struct.c b/source/libads/ads_struct.c
index 44bcdf7..8cc2f12 100644
--- a/source/libads/ads_struct.c
+++ b/source/libads/ads_struct.c
@@ -29,7 +29,8 @@ char *ads_build_path(const char *realm, const char *sep, const char *field, int
 	int numbits = 0;
 	char *ret;
 	int len;
-	
+	char *saveptr;
+
 	r = SMB_STRDUP(realm);
 
 	if (!r || !*r) {
@@ -51,11 +52,11 @@ char *ads_build_path(const char *realm, const char *sep, const char *field, int
 	}
 
 	strlcpy(ret,field, len);
-	p=strtok(r,sep); 
+	p=strtok_r(r, sep, &saveptr);
 	if (p) {
 		strlcat(ret, p, len);
 	
-		while ((p=strtok(NULL,sep))) {
+		while ((p=strtok_r(NULL, sep, &saveptr)) != NULL) {
 			char *s;
 			if (reverse)
 				asprintf(&s, "%s%s,%s", field, p, ret);
diff --git a/source/modules/vfs_recycle.c b/source/modules/vfs_recycle.c
index fef65ef..da17167 100644
--- a/source/modules/vfs_recycle.c
+++ b/source/modules/vfs_recycle.c
@@ -269,6 +269,7 @@ static bool recycle_create_dir(vfs_handle_struct *handle, const char *dname)
 	char *token;
 	char *tok_str;
 	bool ret = False;
+	char *saveptr;
 
 	mode = recycle_directory_mode(handle);
 
@@ -286,7 +287,8 @@ static bool recycle_create_dir(vfs_handle_struct *handle, const char *dname)
 	}
 
 	/* Create directory tree if neccessary */
-	for(token = strtok(tok_str, "/"); token; token = strtok(NULL, "/")) {
+	for(token = strtok_r(tok_str, "/", &saveptr); token;
+	    token = strtok_r(NULL, "/", &saveptr)) {
 		safe_strcat(new_dir, token, len);
 		if (recycle_directory_exist(handle, new_dir))
 			DEBUG(10, ("recycle: dir %s already exists\n", new_dir));
diff --git a/source/nmbd/nmbd_processlogon.c b/source/nmbd/nmbd_processlogon.c
index 0ff0afd..10833e8 100644
--- a/source/nmbd/nmbd_processlogon.c
+++ b/source/nmbd/nmbd_processlogon.c
@@ -399,6 +399,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
 					char *component, *dc, *q1;
 					char *q_orig = q;
 					int str_offset;
+					char *saveptr;
 
 					domain = get_mydnsdomname(talloc_tos());
 					if (!domain) {
@@ -444,7 +445,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
 					str_offset = q - q_orig;
 					dc = domain;
 					q1 = q;
-					while ((component = strtok(dc, "."))) {
+					while ((component = strtok_r(dc, ".", &saveptr)) != NULL) {
 						dc = NULL;
 						if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 1) {
 							return;
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 0796a78..c1d26af 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -4709,6 +4709,7 @@ static void lp_add_auto_services(char *str)
 	char *s;
 	char *p;
 	int homes;
+	char *saveptr;
 
 	if (!str)
 		return;
@@ -4719,7 +4720,8 @@ static void lp_add_auto_services(char *str)
 
 	homes = lp_servicenumber(HOMES_NAME);
 
-	for (p = strtok(s, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) {
+	for (p = strtok_r(s, LIST_SEP, &saveptr); p;
+	     p = strtok_r(NULL, LIST_SEP, &saveptr)) {
 		char *home;
 
 		if (lp_servicenumber(p) >= 0)
diff --git a/source/printing/load.c b/source/printing/load.c
index f8aba39..23144d5 100644
--- a/source/printing/load.c
+++ b/source/printing/load.c
@@ -28,6 +28,7 @@ static void add_auto_printers(void)
 	const char *p;
 	int pnum = lp_servicenumber(PRINTERS_NAME);
 	char *str;
+	char *saveptr;
 
 	if (pnum < 0)
 		return;
@@ -35,7 +36,8 @@ static void add_auto_printers(void)
 	if ((str = SMB_STRDUP(lp_auto_services())) == NULL)
 		return;
 
-	for (p = strtok(str, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) {
+	for (p = strtok_r(str, LIST_SEP, &saveptr); p;
+	     p = strtok_r(NULL, LIST_SEP, &saveptr)) {
 		if (lp_servicenumber(p) >= 0)
 			continue;
 		
diff --git a/source/printing/lpq_parse.c b/source/printing/lpq_parse.c
index 6dcddb6..afa3b48 100644
--- a/source/printing/lpq_parse.c
+++ b/source/printing/lpq_parse.c
@@ -127,6 +127,7 @@ static bool parse_lpq_bsd(char *line,print_queue_struct *buf,bool first)
 	int  count = 0;
 	TALLOC_CTX *ctx = talloc_tos();
 	char *line2 = NULL;
+	char *saveptr;
 
 	line2 = talloc_strdup(ctx, line);
 	if (!line2) {
@@ -144,10 +145,11 @@ static bool parse_lpq_bsd(char *line,print_queue_struct *buf,bool first)
 #endif	/* OSF1 */
 
 	/* FIXME: Use next_token_talloc rather than strtok! */
-	tok[0] = strtok(line2," \t");
+	tok[0] = strtok_r(line2," \t", &saveptr);
 	count++;
 
-	while ((count < MAXTOK) && ((tok[count] = strtok(NULL," \t")) != NULL)) {
+	while ((count < MAXTOK)
+	       && ((tok[count] = strtok_r(NULL, " \t", &saveptr)) != NULL)) {
 		count++;
 	}
 
diff --git a/source/printing/print_aix.c b/source/printing/print_aix.c
index fd85ca0..57590cc 100644
--- a/source/printing/print_aix.c
+++ b/source/printing/print_aix.c
@@ -59,8 +59,9 @@ bool aix_cache_reload(void)
 				continue;
 
 			if ((p = strchr_m(line, ':'))) {
+				char *saveptr;
 				*p = '\0';
-				p = strtok(line, ":");
+				p = strtok_r(line, ":", &saveptr);
 				if (strcmp(p, "bsh") != 0) {
 					name = talloc_strdup(ctx, p);
 					if (!name) {
diff --git a/source/rpcclient/cmd_spoolss.c b/source/rpcclient/cmd_spoolss.c
index a7969bd..d98cb99 100644
--- a/source/rpcclient/cmd_spoolss.c
+++ b/source/rpcclient/cmd_spoolss.c
@@ -1222,9 +1222,10 @@ void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch)
 static char* get_driver_3_param (char* str, const char* delim, UNISTR* dest)
 {
 	char	*ptr;
+	char *saveptr;
 
 	/* get the next token */
-	ptr = strtok(str, delim);
+	ptr = strtok_r(str, delim, &saveptr);
 
 	/* a string of 'NULL' is used to represent an empty
 	   parameter because two consecutive delimiters
@@ -1251,7 +1252,8 @@ static bool init_drv_info_3_members ( TALLOC_CTX *mem_ctx, DRIVER_INFO_3 *info,
 {
 	char	*str, *str2;
 	uint32	len, i;
-	
+	char *saveptr;
+
 	/* fill in the UNISTR fields */
 	str = get_driver_3_param (args, ":", &info->name);
 	str = get_driver_3_param (NULL, ":", &info->driverpath);
@@ -1266,13 +1268,13 @@ static bool init_drv_info_3_members ( TALLOC_CTX *mem_ctx, DRIVER_INFO_3 *info,
 	str = str2;			
 
 	/* begin to strip out each filename */
-	str = strtok(str, ",");		
+	str = strtok_r(str, ",", &saveptr);
 	len = 0;
 	while (str != NULL)
 	{
 		/* keep a cumlative count of the str lengths */
 		len += strlen(str)+1;
-		str = strtok(NULL, ",");
+		str = strtok_r(NULL, ",", &saveptr);
 	}
 
 	/* allocate the space; add one extra slot for a terminating NULL.
diff --git a/source/smbd/msdfs.c b/source/smbd/msdfs.c
index 4ae7356..8ffa0f7 100644
--- a/source/smbd/msdfs.c
+++ b/source/smbd/msdfs.c
@@ -288,12 +288,13 @@ static bool parse_msdfs_symlink(TALLOC_CTX *ctx,
 	char **alt_path = NULL;
 	int count = 0, i;
 	struct referral *reflist;
+	char *saveptr;
 
 	temp = talloc_strdup(ctx, target);
 	if (!temp) {
 		return False;
 	}
-	prot = strtok(temp,":");
+	prot = strtok_r(temp, ":", &saveptr);
 	if (!prot) {
 		DEBUG(0,("parse_msdfs_symlink: invalid path !\n"));
 		return False;
@@ -306,7 +307,7 @@ static bool parse_msdfs_symlink(TALLOC_CTX *ctx,
 
 	/* parse out the alternate paths */
 	while((count<MAX_REFERRAL_COUNT) &&
-	      ((alt_path[count] = strtok(NULL,",")) != NULL)) {
+	      ((alt_path[count] = strtok_r(NULL, ",", &saveptr)) != NULL)) {
 		count++;
 	}
 
diff --git a/source/smbd/password.c b/source/smbd/password.c
index 6b517c3..85e1ccf 100644
--- a/source/smbd/password.c
+++ b/source/smbd/password.c
@@ -759,6 +759,7 @@ bool authorise_login(int snum, fstring user, DATA_BLOB password,
 	if (!ok) {
 		char *auser;
 		char *user_list = NULL;
+		char *saveptr;
 
 		if ( session_userlist )
 			user_list = SMB_STRDUP(session_userlist);
@@ -768,8 +769,9 @@ bool authorise_login(int snum, fstring user, DATA_BLOB password,
 		if (!user_list)
 			return(False);
 
-		for (auser=strtok(user_list,LIST_SEP); !ok && auser;
-		     auser = strtok(NULL,LIST_SEP)) {
+		for (auser = strtok_r(user_list, LIST_SEP, &saveptr);
+		     !ok && auser;
+		     auser = strtok_r(NULL, LIST_SEP, &saveptr)) {
 			fstring user2;
 			fstrcpy(user2,auser);
 			if (!user_ok(user2,snum))
@@ -792,6 +794,7 @@ bool authorise_login(int snum, fstring user, DATA_BLOB password,
 		TALLOC_CTX *ctx = talloc_tos();
 		char *auser;
 		char *user_list = talloc_strdup(ctx, lp_username(snum));
+		char *saveptr;
 
 		if (!user_list) {
 			goto check_guest;
@@ -806,8 +809,9 @@ bool authorise_login(int snum, fstring user, DATA_BLOB password,
 			goto check_guest;
 		}
 
-		for (auser=strtok(user_list,LIST_SEP); auser && !ok;
-		     auser = strtok(NULL,LIST_SEP)) {
+		for (auser = strtok_r(user_list, LIST_SEP, &saveptr);
+		     auser && !ok;
+		     auser = strtok_r(NULL, LIST_SEP, &saveptr)) {
 			if (*auser == '@') {
 				auser = validate_group(auser+1,password,snum);
 				if (auser) {
diff --git a/source/torture/torture.c b/source/torture/torture.c
index 070474c..8d67e51 100644
--- a/source/torture/torture.c
+++ b/source/torture/torture.c
@@ -890,6 +890,7 @@ static bool run_netbench(int client)
 	}
 
 	while (fgets(line, sizeof(line)-1, f)) {
+		char *saveptr;
 		line_count++;
 
 		line[strlen(line)-1] = 0;
@@ -899,9 +900,9 @@ static bool run_netbench(int client)
 		all_string_sub(line,"client1", cname, sizeof(line));
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list