use next_token instead of strtok.
authorSimo Sorce <idra@samba.org>
Thu, 21 Jun 2001 23:33:12 +0000 (23:33 +0000)
committerSimo Sorce <idra@samba.org>
Thu, 21 Jun 2001 23:33:12 +0000 (23:33 +0000)
single elemnts of list cannot be longer than a pstring (1024B now)

source/param/loadparm.c

index edda04c36bfc5544743812b50247b110c5ecb53b..1527dd1e695ed89ad1d914aaac1c522d17f10537 100644 (file)
@@ -3677,13 +3677,14 @@ char *lp_printername(int snum)
 char **lp_list_make(char *string)
 {
        char **list, **rlist;
-       char *str;
-       char *tok;
+       char *str, *s;
        int num, lsize;
+       pstring tok;
        
        if (!string || !*string) return NULL;
-       str = strdup(string);
+       s = strdup(string);
        if (!str || !*str) return NULL;
+       str = s;
        
        list = (char**)malloc(((sizeof(char**)) * P_LIST_ABS));
        if (!list) {
@@ -3695,9 +3696,9 @@ char **lp_list_make(char *string)
        
        num = 0;
        
-       for (tok = strtok(str, LIST_SEP); tok; tok = strtok(NULL, LIST_SEP))
+       while (*str)
        {
-               if (!*tok) continue;
+               if (!next_token(&str, tok, LIST_SEP, sizeof(pstring))) continue;
                
                if ((num +1) == lsize) {
                        lsize += P_LIST_ABS;
@@ -3721,7 +3722,7 @@ char **lp_list_make(char *string)
                num++;  
        }
        
-       free (str);
+       free (s);
        return list;
 }