summaryrefslogtreecommitdiffstats
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-06-21 09:10:42 +0000
committerAndrew Tridgell <tridge@samba.org>2001-06-21 09:10:42 +0000
commit91b8a8d1d21b810b6aca44ce647837669efd6dcf (patch)
tree2490cec37a9ae7f9f9ad9adabac033b41e26c07b /source3/nsswitch
parent4ff011d88ef5b79b92d2cea1abe32c93bc03f724 (diff)
downloadsamba-91b8a8d1d21b810b6aca44ce647837669efd6dcf.tar.gz
samba-91b8a8d1d21b810b6aca44ce647837669efd6dcf.tar.xz
samba-91b8a8d1d21b810b6aca44ce647837669efd6dcf.zip
next_token() was supposed to be a reentrant replacement for strtok(),
but the code suffered from bitrot and is not now reentrant. That means we can get bizarre behaviour i've fixed this by making next_token() reentrant and creating a next_token_nr() that is a small non-reentrant wrapper for those lumps of code (mostly smbclient) that have come to rely on the non-reentrant behaviour (This used to be commit 674ee2f1d12b0afc164a9e9072758fd1c5e54df7)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/winbind_nss.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/source3/nsswitch/winbind_nss.c b/source3/nsswitch/winbind_nss.c
index 5e3e77517cf..a2816bfdd3f 100644
--- a/source3/nsswitch/winbind_nss.c
+++ b/source3/nsswitch/winbind_nss.c
@@ -73,33 +73,27 @@ static char *get_static(char **buffer, int *buflen, int len)
lib/util_str.c as I really don't want to have to link in any other
objects if I can possibly avoid it. */
-static char *last_ptr = NULL;
-
-BOOL next_token(char **ptr, char *buff, char *sep, size_t bufsize)
+BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize)
{
char *s;
BOOL quoted;
size_t len=1;
-
- if (!ptr) ptr = &last_ptr;
+
if (!ptr) return(False);
-
+
s = *ptr;
-
+
/* default to simple separators */
if (!sep) sep = " \t\n\r";
-
+
/* find the first non sep char */
- while(*s && strchr(sep,*s)) s++;
-
+ while (*s && strchr(sep,*s)) s++;
+
/* nothing left? */
if (! *s) return(False);
-
+
/* copy over the token */
- for (quoted = False;
- len < bufsize && *s && (quoted || !strchr(sep,*s));
- s++) {
-
+ for (quoted = False; len < bufsize && *s && (quoted || !strchr(sep,*s)); s++) {
if (*s == '\"') {
quoted = !quoted;
} else {
@@ -107,14 +101,14 @@ BOOL next_token(char **ptr, char *buff, char *sep, size_t bufsize)
*buff++ = *s;
}
}
-
+
*ptr = (*s) ? s+1 : s;
*buff = 0;
- last_ptr = *ptr;
-
+
return(True);
}
+
/* Fill a pwent structure from a winbindd_response structure. We use
the static data passed to us by libc to put strings and stuff in.
Return NSS_STATUS_TRYAGAIN if we run out of memory. */