1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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 commit is contained in:
Andrew Tridgell 0001-01-01 00:00:00 +00:00
parent 86613493a9
commit 674ee2f1d1
14 changed files with 157 additions and 294 deletions

View File

@ -287,7 +287,7 @@ static void cmd_cd(void)
{
fstring buf;
if (next_token(NULL,buf,NULL,sizeof(buf)))
if (next_token_nr(NULL,buf,NULL,sizeof(buf)))
do_cd(buf);
else
DEBUG(0,("Current directory is %s\n",cur_dir));
@ -586,7 +586,7 @@ static void cmd_dir(void)
if(mask[strlen(mask)-1]!='\\')
pstrcat(mask,"\\");
if (next_token(NULL,buf,NULL,sizeof(buf))) {
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
dos_format(p);
if (*p == '\\')
pstrcpy(mask,p);
@ -620,7 +620,7 @@ static void cmd_du(void)
if(mask[strlen(mask)-1]!='\\')
pstrcat(mask,"\\");
if (next_token(NULL,buf,NULL,sizeof(buf))) {
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
dos_format(p);
if (*p == '\\')
pstrcpy(mask,p);
@ -758,14 +758,14 @@ static void cmd_get(void)
p = rname + strlen(rname);
if (!next_token(NULL,p,NULL,sizeof(rname)-strlen(rname))) {
if (!next_token_nr(NULL,p,NULL,sizeof(rname)-strlen(rname))) {
DEBUG(0,("get <filename>\n"));
return;
}
pstrcpy(lname,p);
dos_clean_name(rname);
next_token(NULL,lname,NULL,sizeof(lname));
next_token_nr(NULL,lname,NULL,sizeof(lname));
do_get(rname, lname);
}
@ -857,7 +857,7 @@ static void cmd_more(void)
}
close(fd);
if (!next_token(NULL,rname+strlen(rname),NULL,sizeof(rname)-strlen(rname))) {
if (!next_token_nr(NULL,rname+strlen(rname),NULL,sizeof(rname)-strlen(rname))) {
DEBUG(0,("more <filename>\n"));
unlink(lname);
return;
@ -893,7 +893,7 @@ static void cmd_mget(void)
abort_mget = False;
while (next_token(NULL,p,NULL,sizeof(buf))) {
while (next_token_nr(NULL,p,NULL,sizeof(buf))) {
pstrcpy(mget_mask,cur_dir);
if(mget_mask[strlen(mget_mask)-1]!='\\')
pstrcat(mget_mask,"\\");
@ -951,7 +951,7 @@ static void cmd_mkdir(void)
pstrcpy(mask,cur_dir);
if (!next_token(NULL,p,NULL,sizeof(buf))) {
if (!next_token_nr(NULL,p,NULL,sizeof(buf))) {
if (!recurse)
DEBUG(0,("mkdir <dirname>\n"));
return;
@ -1090,13 +1090,13 @@ static void cmd_put(void)
pstrcpy(rname,cur_dir);
pstrcat(rname,"\\");
if (!next_token(NULL,p,NULL,sizeof(buf))) {
if (!next_token_nr(NULL,p,NULL,sizeof(buf))) {
DEBUG(0,("put <filename>\n"));
return;
}
pstrcpy(lname,p);
if (next_token(NULL,p,NULL,sizeof(buf)))
if (next_token_nr(NULL,p,NULL,sizeof(buf)))
pstrcat(rname,p);
else
pstrcat(rname,lname);
@ -1167,7 +1167,7 @@ static BOOL seek_list(struct file_list *list, char *name)
static void cmd_select(void)
{
pstrcpy(fileselection,"");
next_token(NULL,fileselection,NULL,sizeof(fileselection));
next_token_nr(NULL,fileselection,NULL,sizeof(fileselection));
}
/****************************************************************************
@ -1241,7 +1241,7 @@ static void cmd_mput(void)
fstring buf;
char *p=buf;
while (next_token(NULL,p,NULL,sizeof(buf))) {
while (next_token_nr(NULL,p,NULL,sizeof(buf))) {
int ret;
struct file_list *temp_list;
char *quest, *lname, *rname;
@ -1335,14 +1335,14 @@ static void cmd_cancel(void)
fstring buf;
int job;
if (!next_token(NULL,buf,NULL,sizeof(buf))) {
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
printf("cancel <jobid> ...\n");
return;
}
do {
job = atoi(buf);
do_cancel(job);
} while (next_token(NULL,buf,NULL,sizeof(buf)));
} while (next_token_nr(NULL,buf,NULL,sizeof(buf)));
}
@ -1355,7 +1355,7 @@ static void cmd_print(void)
pstring rname;
char *p;
if (!next_token(NULL,lname,NULL, sizeof(lname))) {
if (!next_token_nr(NULL,lname,NULL, sizeof(lname))) {
DEBUG(0,("print <filename>\n"));
return;
}
@ -1422,7 +1422,7 @@ static void cmd_del(void)
pstrcpy(mask,cur_dir);
if (!next_token(NULL,buf,NULL,sizeof(buf))) {
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
DEBUG(0,("del <filename>\n"));
return;
}
@ -1440,7 +1440,7 @@ static void cmd_open(void)
pstrcpy(mask,cur_dir);
if (!next_token(NULL,buf,NULL,sizeof(buf))) {
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
DEBUG(0,("del <filename>\n"));
return;
}
@ -1460,7 +1460,7 @@ static void cmd_rmdir(void)
pstrcpy(mask,cur_dir);
if (!next_token(NULL,buf,NULL,sizeof(buf))) {
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
DEBUG(0,("rmdir <dirname>\n"));
return;
}
@ -1483,8 +1483,8 @@ static void cmd_rename(void)
pstrcpy(src,cur_dir);
pstrcpy(dest,cur_dir);
if (!next_token(NULL,buf,NULL,sizeof(buf)) ||
!next_token(NULL,buf2,NULL, sizeof(buf2))) {
if (!next_token_nr(NULL,buf,NULL,sizeof(buf)) ||
!next_token_nr(NULL,buf2,NULL, sizeof(buf2))) {
DEBUG(0,("rename <src> <dest>\n"));
return;
}
@ -1518,7 +1518,7 @@ static void cmd_newer(void)
BOOL ok;
SMB_STRUCT_STAT sbuf;
ok = next_token(NULL,buf,NULL,sizeof(buf));
ok = next_token_nr(NULL,buf,NULL,sizeof(buf));
if (ok && (sys_stat(buf,&sbuf) == 0)) {
newer_than = sbuf.st_mtime;
DEBUG(1,("Getting files newer than %s",
@ -1538,7 +1538,7 @@ static void cmd_archive(void)
{
fstring buf;
if (next_token(NULL,buf,NULL,sizeof(buf))) {
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
archive_level = atoi(buf);
} else
DEBUG(0,("Archive level is %d\n",archive_level));
@ -1584,7 +1584,7 @@ static void cmd_printmode(void)
fstring buf;
fstring mode;
if (next_token(NULL,buf,NULL,sizeof(buf))) {
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
if (strequal(buf,"text")) {
printmode = 0;
} else {
@ -1619,7 +1619,7 @@ static void cmd_lcd(void)
fstring buf;
pstring d;
if (next_token(NULL,buf,NULL,sizeof(buf)))
if (next_token_nr(NULL,buf,NULL,sizeof(buf)))
chdir(buf);
DEBUG(2,("the local directory is now %s\n",sys_getwd(d)));
}
@ -1794,7 +1794,7 @@ static void cmd_help(void)
int i=0,j;
fstring buf;
if (next_token(NULL,buf,NULL,sizeof(buf))) {
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
if ((i = process_tok(buf)) >= 0)
DEBUG(0,("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description));
} else {
@ -1834,7 +1834,7 @@ static void process_command_string(char *cmd)
/* and get the first part of the command */
ptr = line;
if (!next_token(&ptr,tok,NULL,sizeof(tok))) continue;
if (!next_token_nr(&ptr,tok,NULL,sizeof(tok))) continue;
if ((i = process_tok(tok)) >= 0) {
commands[i].fn();
@ -1945,7 +1945,7 @@ static void process_stdin(void)
/* and get the first part of the command */
ptr = line;
if (!next_token(&ptr,tok,NULL,sizeof(tok))) continue;
if (!next_token_nr(&ptr,tok,NULL,sizeof(tok))) continue;
if ((i = process_tok(tok)) >= 0) {
commands[i].fn();

View File

@ -1322,7 +1322,7 @@ void cmd_block(void)
fstring buf;
int block;
if (!next_token(NULL,buf,NULL,sizeof(buf)))
if (!next_token_nr(NULL,buf,NULL,sizeof(buf)))
{
DEBUG(0, ("blocksize <n>\n"));
return;
@ -1346,7 +1346,7 @@ void cmd_tarmode(void)
{
fstring buf;
while (next_token(NULL,buf,NULL,sizeof(buf))) {
while (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
if (strequal(buf, "full"))
tar_inc=False;
else if (strequal(buf, "inc"))
@ -1392,7 +1392,7 @@ void cmd_setmode(void)
attra[0] = attra[1] = 0;
if (!next_token(NULL,buf,NULL,sizeof(buf)))
if (!next_token_nr(NULL,buf,NULL,sizeof(buf)))
{
DEBUG(0, ("setmode <filename> <[+|-]rsha>\n"));
return;
@ -1401,7 +1401,7 @@ void cmd_setmode(void)
safe_strcpy(fname, cur_dir, sizeof(pstring));
safe_strcat(fname, buf, sizeof(pstring));
while (next_token(NULL,buf,NULL,sizeof(buf))) {
while (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
q=buf;
while(*q)
@ -1443,7 +1443,7 @@ void cmd_tar(void)
char **argl;
int argcl;
if (!next_token(NULL,buf,NULL,sizeof(buf)))
if (!next_token_nr(NULL,buf,NULL,sizeof(buf)))
{
DEBUG(0,("tar <c|x>[IXbgan] <filename>\n"));
return;

View File

@ -628,8 +628,9 @@ int create_pipe_socket(char *dir, int dir_perms,
/* The following definitions come from lib/util_str.c */
void set_first_token(char *ptr);
BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize);
BOOL next_token_nr(char **ptr,char *buff,char *sep, size_t bufsize);
void set_first_token(char *ptr);
char **toktocliplist(int *ctok, char *sep);
int StrCaseCmp(const char *s, const char *t);
int StrnCaseCmp(const char *s, const char *t, size_t n);
@ -711,9 +712,6 @@ int isxdigit_w( smb_ucs2_t val);
int isspace_w( smb_ucs2_t val);
smb_ucs2_t toupper_w( smb_ucs2_t val );
smb_ucs2_t tolower_w( smb_ucs2_t val );
void set_first_token_w(smb_ucs2_t *ptr);
BOOL next_token_w(smb_ucs2_t **ptr, smb_ucs2_t *buff, smb_ucs2_t *sep, size_t bufsize);
smb_ucs2_t **toktocliplist_w(int *ctok, smb_ucs2_t *sep);
int StrCaseCmp_w(const smb_ucs2_t *s, const smb_ucs2_t *t);
int StrnCaseCmp_w(const smb_ucs2_t *s, const smb_ucs2_t *t, size_t n);
BOOL strequal_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);

View File

@ -292,14 +292,14 @@ static BOOL get_cmd_args(char *line)
cmd_argv = NULL;
/* get the first part of the command */
if (!next_token(&ptr, tok, NULL, sizeof(tok)))
if (!next_token_nr(&ptr, tok, NULL, sizeof(tok)))
return False;
do
{
add_chars_to_array(&cmd_argc, &cmd_argv, tok);
}
while (next_token(NULL, tok, NULL, sizeof(tok)));
while (next_token_nr(NULL, tok, NULL, sizeof(tok)));
add_chars_to_array(&cmd_argc, &cmd_argv, NULL);

View File

@ -1658,7 +1658,7 @@ BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name)
return False;
}
if (next_token(NULL, tmp, "\n\r", sizeof(tmp)))
if (next_token(&full_keyname, tmp, "\n\r", sizeof(tmp)))
{
fstrcpy(key_name, tmp);
}

View File

@ -23,13 +23,6 @@
extern int DEBUGLEVEL;
static char *last_ptr=NULL;
void set_first_token(char *ptr)
{
last_ptr = ptr;
}
/****************************************************************************
Get the next token from a string, return False if none found
handles double-quotes.
@ -38,77 +31,99 @@ Extensively modified by Andrew.Tridgell@anu.edu.au
****************************************************************************/
BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize)
{
char *s;
BOOL quoted;
size_t len=1;
char *s;
BOOL quoted;
size_t len=1;
if (!ptr) ptr = &last_ptr;
if (!ptr) return(False);
if (!ptr) return(False);
s = *ptr;
s = *ptr;
/* default to simple separators */
if (!sep) sep = " \t\n\r";
/* default to simple separators */
if (!sep) sep = " \t\n\r";
/* find the first non sep char */
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++)
{
if (*s == '\"') {
quoted = !quoted;
} else {
len++;
*buff++ = *s;
}
}
*ptr = (*s) ? s+1 : s;
*buff = 0;
last_ptr = *ptr;
return(True);
/* find the first non sep char */
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++) {
if (*s == '\"') {
quoted = !quoted;
} else {
len++;
*buff++ = *s;
}
}
*ptr = (*s) ? s+1 : s;
*buff = 0;
return(True);
}
/****************************************************************************
This is like next_token but is not re-entrant and "remembers" the first
parameter so you can pass NULL. This is useful for user interface code
but beware the fact that it is not re-entrant!
****************************************************************************/
static char *last_ptr=NULL;
BOOL next_token_nr(char **ptr,char *buff,char *sep, size_t bufsize)
{
BOOL ret;
if (!ptr) ptr = &last_ptr;
ret = next_token(ptr, buff, sep, bufsize);
last_ptr = *ptr;
return ret;
}
void set_first_token(char *ptr)
{
last_ptr = ptr;
}
/****************************************************************************
Convert list of tokens to array; dependent on above routine.
Uses last_ptr from above - bit of a hack.
****************************************************************************/
char **toktocliplist(int *ctok, char *sep)
{
char *s=last_ptr;
int ictok=0;
char **ret, **iret;
char *s=last_ptr;
int ictok=0;
char **ret, **iret;
if (!sep) sep = " \t\n\r";
if (!sep) sep = " \t\n\r";
while(*s && strchr(sep,*s)) s++;
while(*s && strchr(sep,*s)) s++;
/* nothing left? */
if (!*s) return(NULL);
/* nothing left? */
if (!*s) return(NULL);
do {
ictok++;
while(*s && (!strchr(sep,*s))) s++;
while(*s && strchr(sep,*s)) *s++=0;
} while(*s);
do {
ictok++;
while(*s && (!strchr(sep,*s))) s++;
while(*s && strchr(sep,*s)) *s++=0;
} while(*s);
*ctok=ictok;
s=last_ptr;
if (!(ret=iret=malloc(ictok*sizeof(char *)))) return NULL;
while(ictok--) {
*iret++=s;
while(*s++);
while(!*s) s++;
}
*ctok=ictok;
s=last_ptr;
if (!(ret=iret=malloc(ictok*sizeof(char *)))) return NULL;
while(ictok--) {
*iret++=s;
while(*s++);
while(!*s) s++;
}
return ret;
return ret;
}

View File

@ -1169,133 +1169,6 @@ smb_ucs2_t tolower_w( smb_ucs2_t val )
return map_table_lower(val);
}
static smb_ucs2_t *last_ptr = NULL;
void set_first_token_w(smb_ucs2_t *ptr)
{
last_ptr = ptr;
}
/****************************************************************************
Get the next token from a string, return False if none found
handles double-quotes.
Based on a routine by GJC@VILLAGE.COM.
Extensively modified by Andrew.Tridgell@anu.edu.au
bufsize is in bytes.
****************************************************************************/
static smb_ucs2_t sep_list[] = { (smb_ucs2_t)' ', (smb_ucs2_t)'\t', (smb_ucs2_t)'\n', (smb_ucs2_t)'\r', 0};
static smb_ucs2_t quotechar = (smb_ucs2_t)'\"';
BOOL next_token_w(smb_ucs2_t **ptr, smb_ucs2_t *buff, smb_ucs2_t *sep, size_t bufsize)
{
smb_ucs2_t *s;
BOOL quoted;
size_t len=1;
/*
* Convert bufsize to smb_ucs2_t units.
*/
bufsize /= sizeof(smb_ucs2_t);
if (!ptr)
ptr = &last_ptr;
if (!ptr)
return(False);
s = *ptr;
/*
* Default to simple separators.
*/
if (!sep)
sep = sep_list;
/*
* Find the first non sep char.
*/
while(*s && strchr_w(sep,*s))
s++;
/*
* Nothing left ?
*/
if (!*s)
return(False);
/*
* Copy over the token.
*/
for (quoted = False; len < bufsize && *s && (quoted || !strchr_w(sep,*s)); s++) {
if (*s == quotechar) {
quoted = !quoted;
} else {
len++;
*buff++ = *s;
}
}
*ptr = (*s) ? s+1 : s;
*buff = 0;
last_ptr = *ptr;
return(True);
}
/****************************************************************************
Convert list of tokens to array; dependent on above routine.
Uses last_ptr from above - bit of a hack.
****************************************************************************/
smb_ucs2_t **toktocliplist_w(int *ctok, smb_ucs2_t *sep)
{
smb_ucs2_t *s=last_ptr;
int ictok=0;
smb_ucs2_t **ret, **iret;
if (!sep)
sep = sep_list;
while(*s && strchr_w(sep,*s))
s++;
/*
* Nothing left ?
*/
if (!*s)
return(NULL);
do {
ictok++;
while(*s && (!strchr_w(sep,*s)))
s++;
while(*s && strchr_w(sep,*s))
*s++=0;
} while(*s);
*ctok = ictok;
s = last_ptr;
if (!(ret=iret=malloc(ictok*sizeof(smb_ucs2_t *))))
return NULL;
while(ictok--) {
*iret++=s;
while(*s++)
;
while(!*s)
s++;
}
return ret;
}
/*******************************************************************
Case insensitive string compararison.
********************************************************************/
@ -1715,29 +1588,6 @@ size_t strhex_to_str_w(char *p, size_t len, const smb_ucs2_t *strhex)
return num_chars;
}
/****************************************************************************
Check if a string is part of a list.
****************************************************************************/
BOOL in_list_w(smb_ucs2_t *s,smb_ucs2_t *list,BOOL casesensitive)
{
wpstring tok;
smb_ucs2_t *p=list;
if (!list)
return(False);
while (next_token_w(&p,tok,LIST_SEP_W,sizeof(tok))) {
if (casesensitive) {
if (strcmp_w(tok,s) == 0)
return(True);
} else {
if (StrCaseCmp_w(tok,s) == 0)
return(True);
}
}
return(False);
}
/* This is used to prevent lots of mallocs of size 2 */
static smb_ucs2_t *null_string = NULL;

View File

@ -139,9 +139,9 @@ static void cli_issue_write(struct cli_state *cli, int fnum, off_t offset, uint1
memset(cli->inbuf,'\0',smb_size);
if (size > 0xFFFF)
set_message(cli->outbuf,14,size,True);
set_message(cli->outbuf,14,0,True);
else
set_message(cli->outbuf,12,size,True);
set_message(cli->outbuf,12,0,True);
CVAL(cli->outbuf,smb_com) = SMBwriteX;
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@ -162,6 +162,7 @@ static void cli_issue_write(struct cli_state *cli, int fnum, off_t offset, uint1
p = smb_base(cli->outbuf) + SVAL(cli->outbuf,smb_vwv11);
memcpy(p, buf, size);
cli_setup_bcc(cli, p+size);
SSVAL(cli->outbuf,smb_mid,cli->mid + i);
@ -240,7 +241,7 @@ ssize_t cli_smbwrite(struct cli_state *cli,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
set_message(cli->outbuf,5, 3 + size,True);
set_message(cli->outbuf,5, 0,True);
CVAL(cli->outbuf,smb_com) = SMBwrite;
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@ -253,8 +254,10 @@ ssize_t cli_smbwrite(struct cli_state *cli,
p = smb_buf(cli->outbuf);
*p++ = 1;
SSVAL(p, 0, size);
memcpy(p+2, buf, size);
SSVAL(p, 0, size); p += 2;
memcpy(p, buf, size); p += size;
cli_setup_bcc(cli, p);
cli_send_smb(cli);
if (!cli_receive_smb(cli)) {

View File

@ -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. */

View File

@ -91,7 +91,7 @@ void cmd_reg_enum(struct client_info *info)
DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd));
if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
if (!next_token_nr(NULL, full_keyname, NULL, sizeof(full_keyname)))
{
fprintf(out_hnd, "regenum <key_name>\n");
return;
@ -250,7 +250,7 @@ void cmd_reg_query_key(struct client_info *info)
DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd));
if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
if (!next_token_nr(NULL, full_keyname, NULL, sizeof(full_keyname)))
{
fprintf(out_hnd, "regquery key_name\n");
return;
@ -349,7 +349,7 @@ void cmd_reg_create_val(struct client_info *info)
DEBUG(5, ("cmd_reg_create_val: smb_cli->fd:%d\n", smb_cli->fd));
if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
if (!next_token_nr(NULL, full_keyname, NULL, sizeof(full_keyname)))
{
fprintf(out_hnd, "regcreate <val_name> <val_type> <val>\n");
return;
@ -363,7 +363,7 @@ void cmd_reg_create_val(struct client_info *info)
return;
}
if (!next_token(NULL, tmp, NULL, sizeof(tmp)))
if (!next_token_nr(NULL, tmp, NULL, sizeof(tmp)))
{
fprintf(out_hnd, "regcreate <val_name> <val_type (1|4)> <val>\n");
return;
@ -377,7 +377,7 @@ void cmd_reg_create_val(struct client_info *info)
return;
}
if (!next_token(NULL, tmp, NULL, sizeof(tmp)))
if (!next_token_nr(NULL, tmp, NULL, sizeof(tmp)))
{
fprintf(out_hnd, "regcreate <val_name> <val_type (1|4)> <val>\n");
return;
@ -484,7 +484,7 @@ void cmd_reg_delete_val(struct client_info *info)
DEBUG(5, ("cmd_reg_delete_val: smb_cli->fd:%d\n", smb_cli->fd));
if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
if (!next_token_nr(NULL, full_keyname, NULL, sizeof(full_keyname)))
{
fprintf(out_hnd, "regdelete <val_name>\n");
return;
@ -559,7 +559,7 @@ void cmd_reg_delete_key(struct client_info *info)
DEBUG(5, ("cmd_reg_delete_key: smb_cli->fd:%d\n", smb_cli->fd));
if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
if (!next_token_nr(NULL, full_keyname, NULL, sizeof(full_keyname)))
{
fprintf(out_hnd, "regdeletekey <key_name>\n");
return;
@ -640,7 +640,7 @@ void cmd_reg_create_key(struct client_info *info)
DEBUG(5, ("cmd_reg_create_key: smb_cli->fd:%d\n", smb_cli->fd));
if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
if (!next_token_nr(NULL, full_keyname, NULL, sizeof(full_keyname)))
{
fprintf(out_hnd, "regcreate <key_name> [key_class]\n");
return;
@ -654,7 +654,7 @@ void cmd_reg_create_key(struct client_info *info)
return;
}
if (!next_token(NULL, key_class, NULL, sizeof(key_class)))
if (!next_token_nr(NULL, key_class, NULL, sizeof(key_class)))
{
memset(key_class, 0, sizeof(key_class));
}
@ -735,7 +735,7 @@ void cmd_reg_test_key_sec(struct client_info *info)
DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli->fd));
if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
if (!next_token_nr(NULL, full_keyname, NULL, sizeof(full_keyname)))
{
fprintf(out_hnd, "reggetsec <key_name>\n");
return;
@ -830,7 +830,7 @@ void cmd_reg_get_key_sec(struct client_info *info)
DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli->fd));
if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
if (!next_token_nr(NULL, full_keyname, NULL, sizeof(full_keyname)))
{
fprintf(out_hnd, "reggetsec <key_name>\n");
return;

View File

@ -55,7 +55,7 @@ void cmd_wks_query_info(struct client_info *info)
fstrcat(dest_wks, info->dest_host);
strupper(dest_wks);
if (next_token(NULL, tmp, NULL, sizeof(tmp)))
if (next_token_nr(NULL, tmp, NULL, sizeof(tmp)))
{
info_level = (uint32)strtol(tmp, (char**)NULL, 10);
}

View File

@ -358,13 +358,13 @@ static uint32 do_cmd(struct cli_state *cli, struct cmd_set *cmd_entry, char *cmd
pstring buf;
int argc = 1, i;
next_token(&p, buf, " ", sizeof(buf));
next_token_nr(&p, buf, " ", sizeof(buf));
/* Count number of arguments first time through the loop then
allocate memory and strdup them. */
again:
while(next_token(NULL, buf, " ", sizeof(buf))) {
while(next_token_nr(NULL, buf, " ", sizeof(buf))) {
if (argv) {
argv[argc] = strdup(buf);
}
@ -384,7 +384,7 @@ static uint32 do_cmd(struct cli_state *cli, struct cmd_set *cmd_entry, char *cmd
}
p = cmd;
next_token(&p, buf, " ", sizeof(buf));
next_token_nr(&p, buf, " ", sizeof(buf));
argv[0] = strdup(buf);
argc = 1;
@ -425,7 +425,7 @@ static uint32 process_cmd(struct cli_state *cli, char *cmd)
if (cmd[strlen(cmd) - 1] == '\n')
cmd[strlen(cmd) - 1] = '\0';
if (!next_token(&p, buf, " ", sizeof(buf))) {
if (!next_token_nr(&p, buf, " ", sizeof(buf))) {
return 0;
}

View File

@ -265,7 +265,7 @@ static BOOL process_lockread(blocking_lock_record *blr)
char *outbuf = OutBuffer;
char *inbuf = blr->inbuf;
ssize_t nread = -1;
char *data;
char *data, *p;
int outsize = 0;
SMB_OFF_T startpos;
size_t numtoread;
@ -309,12 +309,15 @@ static BOOL process_lockread(blocking_lock_record *blr)
}
construct_reply_common(inbuf, outbuf);
outsize = set_message(outbuf,5,3,True);
outsize = set_message(outbuf,5,0,True);
outsize += nread;
SSVAL(outbuf,smb_vwv0,nread);
SSVAL(outbuf,smb_vwv5,nread+3);
SSVAL(smb_buf(outbuf),1,nread);
p = smb_buf(outbuf);
*p++ = 1;
SSVAL(p,0,nread); p += 2;
set_message_end(outbuf, p+nread);
DEBUG(3, ( "process_lockread file = %s, fnum=%d num=%d nread=%d\n",
fsp->fsp_name, fsp->fnum, (int)numtoread, (int)nread ) );

View File

@ -266,12 +266,12 @@ static BOOL parse_ace(SEC_ACE *ace, char *str)
/* Only numeric form accepted for flags at present */
if (!(next_token(NULL, tok, "/", sizeof(fstring)) &&
if (!(next_token(&p, tok, "/", sizeof(fstring)) &&
sscanf(tok, "%i", &aflags))) {
return False;
}
if (!next_token(NULL, tok, "/", sizeof(fstring))) {
if (!next_token(&p, tok, "/", sizeof(fstring))) {
return False;
}