mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +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:
parent
86613493a9
commit
674ee2f1d1
@ -287,7 +287,7 @@ static void cmd_cd(void)
|
|||||||
{
|
{
|
||||||
fstring buf;
|
fstring buf;
|
||||||
|
|
||||||
if (next_token(NULL,buf,NULL,sizeof(buf)))
|
if (next_token_nr(NULL,buf,NULL,sizeof(buf)))
|
||||||
do_cd(buf);
|
do_cd(buf);
|
||||||
else
|
else
|
||||||
DEBUG(0,("Current directory is %s\n",cur_dir));
|
DEBUG(0,("Current directory is %s\n",cur_dir));
|
||||||
@ -586,7 +586,7 @@ static void cmd_dir(void)
|
|||||||
if(mask[strlen(mask)-1]!='\\')
|
if(mask[strlen(mask)-1]!='\\')
|
||||||
pstrcat(mask,"\\");
|
pstrcat(mask,"\\");
|
||||||
|
|
||||||
if (next_token(NULL,buf,NULL,sizeof(buf))) {
|
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
|
||||||
dos_format(p);
|
dos_format(p);
|
||||||
if (*p == '\\')
|
if (*p == '\\')
|
||||||
pstrcpy(mask,p);
|
pstrcpy(mask,p);
|
||||||
@ -620,7 +620,7 @@ static void cmd_du(void)
|
|||||||
if(mask[strlen(mask)-1]!='\\')
|
if(mask[strlen(mask)-1]!='\\')
|
||||||
pstrcat(mask,"\\");
|
pstrcat(mask,"\\");
|
||||||
|
|
||||||
if (next_token(NULL,buf,NULL,sizeof(buf))) {
|
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
|
||||||
dos_format(p);
|
dos_format(p);
|
||||||
if (*p == '\\')
|
if (*p == '\\')
|
||||||
pstrcpy(mask,p);
|
pstrcpy(mask,p);
|
||||||
@ -758,14 +758,14 @@ static void cmd_get(void)
|
|||||||
|
|
||||||
p = rname + strlen(rname);
|
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"));
|
DEBUG(0,("get <filename>\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pstrcpy(lname,p);
|
pstrcpy(lname,p);
|
||||||
dos_clean_name(rname);
|
dos_clean_name(rname);
|
||||||
|
|
||||||
next_token(NULL,lname,NULL,sizeof(lname));
|
next_token_nr(NULL,lname,NULL,sizeof(lname));
|
||||||
|
|
||||||
do_get(rname, lname);
|
do_get(rname, lname);
|
||||||
}
|
}
|
||||||
@ -857,7 +857,7 @@ static void cmd_more(void)
|
|||||||
}
|
}
|
||||||
close(fd);
|
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"));
|
DEBUG(0,("more <filename>\n"));
|
||||||
unlink(lname);
|
unlink(lname);
|
||||||
return;
|
return;
|
||||||
@ -893,7 +893,7 @@ static void cmd_mget(void)
|
|||||||
|
|
||||||
abort_mget = False;
|
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);
|
pstrcpy(mget_mask,cur_dir);
|
||||||
if(mget_mask[strlen(mget_mask)-1]!='\\')
|
if(mget_mask[strlen(mget_mask)-1]!='\\')
|
||||||
pstrcat(mget_mask,"\\");
|
pstrcat(mget_mask,"\\");
|
||||||
@ -951,7 +951,7 @@ static void cmd_mkdir(void)
|
|||||||
|
|
||||||
pstrcpy(mask,cur_dir);
|
pstrcpy(mask,cur_dir);
|
||||||
|
|
||||||
if (!next_token(NULL,p,NULL,sizeof(buf))) {
|
if (!next_token_nr(NULL,p,NULL,sizeof(buf))) {
|
||||||
if (!recurse)
|
if (!recurse)
|
||||||
DEBUG(0,("mkdir <dirname>\n"));
|
DEBUG(0,("mkdir <dirname>\n"));
|
||||||
return;
|
return;
|
||||||
@ -1090,13 +1090,13 @@ static void cmd_put(void)
|
|||||||
pstrcpy(rname,cur_dir);
|
pstrcpy(rname,cur_dir);
|
||||||
pstrcat(rname,"\\");
|
pstrcat(rname,"\\");
|
||||||
|
|
||||||
if (!next_token(NULL,p,NULL,sizeof(buf))) {
|
if (!next_token_nr(NULL,p,NULL,sizeof(buf))) {
|
||||||
DEBUG(0,("put <filename>\n"));
|
DEBUG(0,("put <filename>\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pstrcpy(lname,p);
|
pstrcpy(lname,p);
|
||||||
|
|
||||||
if (next_token(NULL,p,NULL,sizeof(buf)))
|
if (next_token_nr(NULL,p,NULL,sizeof(buf)))
|
||||||
pstrcat(rname,p);
|
pstrcat(rname,p);
|
||||||
else
|
else
|
||||||
pstrcat(rname,lname);
|
pstrcat(rname,lname);
|
||||||
@ -1167,7 +1167,7 @@ static BOOL seek_list(struct file_list *list, char *name)
|
|||||||
static void cmd_select(void)
|
static void cmd_select(void)
|
||||||
{
|
{
|
||||||
pstrcpy(fileselection,"");
|
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;
|
fstring buf;
|
||||||
char *p=buf;
|
char *p=buf;
|
||||||
|
|
||||||
while (next_token(NULL,p,NULL,sizeof(buf))) {
|
while (next_token_nr(NULL,p,NULL,sizeof(buf))) {
|
||||||
int ret;
|
int ret;
|
||||||
struct file_list *temp_list;
|
struct file_list *temp_list;
|
||||||
char *quest, *lname, *rname;
|
char *quest, *lname, *rname;
|
||||||
@ -1335,14 +1335,14 @@ static void cmd_cancel(void)
|
|||||||
fstring buf;
|
fstring buf;
|
||||||
int job;
|
int job;
|
||||||
|
|
||||||
if (!next_token(NULL,buf,NULL,sizeof(buf))) {
|
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
|
||||||
printf("cancel <jobid> ...\n");
|
printf("cancel <jobid> ...\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
job = atoi(buf);
|
job = atoi(buf);
|
||||||
do_cancel(job);
|
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;
|
pstring rname;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (!next_token(NULL,lname,NULL, sizeof(lname))) {
|
if (!next_token_nr(NULL,lname,NULL, sizeof(lname))) {
|
||||||
DEBUG(0,("print <filename>\n"));
|
DEBUG(0,("print <filename>\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1422,7 +1422,7 @@ static void cmd_del(void)
|
|||||||
|
|
||||||
pstrcpy(mask,cur_dir);
|
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"));
|
DEBUG(0,("del <filename>\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1440,7 +1440,7 @@ static void cmd_open(void)
|
|||||||
|
|
||||||
pstrcpy(mask,cur_dir);
|
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"));
|
DEBUG(0,("del <filename>\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1460,7 +1460,7 @@ static void cmd_rmdir(void)
|
|||||||
|
|
||||||
pstrcpy(mask,cur_dir);
|
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"));
|
DEBUG(0,("rmdir <dirname>\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1483,8 +1483,8 @@ static void cmd_rename(void)
|
|||||||
pstrcpy(src,cur_dir);
|
pstrcpy(src,cur_dir);
|
||||||
pstrcpy(dest,cur_dir);
|
pstrcpy(dest,cur_dir);
|
||||||
|
|
||||||
if (!next_token(NULL,buf,NULL,sizeof(buf)) ||
|
if (!next_token_nr(NULL,buf,NULL,sizeof(buf)) ||
|
||||||
!next_token(NULL,buf2,NULL, sizeof(buf2))) {
|
!next_token_nr(NULL,buf2,NULL, sizeof(buf2))) {
|
||||||
DEBUG(0,("rename <src> <dest>\n"));
|
DEBUG(0,("rename <src> <dest>\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1518,7 +1518,7 @@ static void cmd_newer(void)
|
|||||||
BOOL ok;
|
BOOL ok;
|
||||||
SMB_STRUCT_STAT sbuf;
|
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)) {
|
if (ok && (sys_stat(buf,&sbuf) == 0)) {
|
||||||
newer_than = sbuf.st_mtime;
|
newer_than = sbuf.st_mtime;
|
||||||
DEBUG(1,("Getting files newer than %s",
|
DEBUG(1,("Getting files newer than %s",
|
||||||
@ -1538,7 +1538,7 @@ static void cmd_archive(void)
|
|||||||
{
|
{
|
||||||
fstring buf;
|
fstring buf;
|
||||||
|
|
||||||
if (next_token(NULL,buf,NULL,sizeof(buf))) {
|
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
|
||||||
archive_level = atoi(buf);
|
archive_level = atoi(buf);
|
||||||
} else
|
} else
|
||||||
DEBUG(0,("Archive level is %d\n",archive_level));
|
DEBUG(0,("Archive level is %d\n",archive_level));
|
||||||
@ -1584,7 +1584,7 @@ static void cmd_printmode(void)
|
|||||||
fstring buf;
|
fstring buf;
|
||||||
fstring mode;
|
fstring mode;
|
||||||
|
|
||||||
if (next_token(NULL,buf,NULL,sizeof(buf))) {
|
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
|
||||||
if (strequal(buf,"text")) {
|
if (strequal(buf,"text")) {
|
||||||
printmode = 0;
|
printmode = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -1619,7 +1619,7 @@ static void cmd_lcd(void)
|
|||||||
fstring buf;
|
fstring buf;
|
||||||
pstring d;
|
pstring d;
|
||||||
|
|
||||||
if (next_token(NULL,buf,NULL,sizeof(buf)))
|
if (next_token_nr(NULL,buf,NULL,sizeof(buf)))
|
||||||
chdir(buf);
|
chdir(buf);
|
||||||
DEBUG(2,("the local directory is now %s\n",sys_getwd(d)));
|
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;
|
int i=0,j;
|
||||||
fstring buf;
|
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)
|
if ((i = process_tok(buf)) >= 0)
|
||||||
DEBUG(0,("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description));
|
DEBUG(0,("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description));
|
||||||
} else {
|
} else {
|
||||||
@ -1834,7 +1834,7 @@ static void process_command_string(char *cmd)
|
|||||||
|
|
||||||
/* and get the first part of the command */
|
/* and get the first part of the command */
|
||||||
ptr = line;
|
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) {
|
if ((i = process_tok(tok)) >= 0) {
|
||||||
commands[i].fn();
|
commands[i].fn();
|
||||||
@ -1945,7 +1945,7 @@ static void process_stdin(void)
|
|||||||
|
|
||||||
/* and get the first part of the command */
|
/* and get the first part of the command */
|
||||||
ptr = line;
|
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) {
|
if ((i = process_tok(tok)) >= 0) {
|
||||||
commands[i].fn();
|
commands[i].fn();
|
||||||
|
@ -1322,7 +1322,7 @@ void cmd_block(void)
|
|||||||
fstring buf;
|
fstring buf;
|
||||||
int block;
|
int block;
|
||||||
|
|
||||||
if (!next_token(NULL,buf,NULL,sizeof(buf)))
|
if (!next_token_nr(NULL,buf,NULL,sizeof(buf)))
|
||||||
{
|
{
|
||||||
DEBUG(0, ("blocksize <n>\n"));
|
DEBUG(0, ("blocksize <n>\n"));
|
||||||
return;
|
return;
|
||||||
@ -1346,7 +1346,7 @@ void cmd_tarmode(void)
|
|||||||
{
|
{
|
||||||
fstring buf;
|
fstring buf;
|
||||||
|
|
||||||
while (next_token(NULL,buf,NULL,sizeof(buf))) {
|
while (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
|
||||||
if (strequal(buf, "full"))
|
if (strequal(buf, "full"))
|
||||||
tar_inc=False;
|
tar_inc=False;
|
||||||
else if (strequal(buf, "inc"))
|
else if (strequal(buf, "inc"))
|
||||||
@ -1392,7 +1392,7 @@ void cmd_setmode(void)
|
|||||||
|
|
||||||
attra[0] = attra[1] = 0;
|
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"));
|
DEBUG(0, ("setmode <filename> <[+|-]rsha>\n"));
|
||||||
return;
|
return;
|
||||||
@ -1401,7 +1401,7 @@ void cmd_setmode(void)
|
|||||||
safe_strcpy(fname, cur_dir, sizeof(pstring));
|
safe_strcpy(fname, cur_dir, sizeof(pstring));
|
||||||
safe_strcat(fname, buf, 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;
|
q=buf;
|
||||||
|
|
||||||
while(*q)
|
while(*q)
|
||||||
@ -1443,7 +1443,7 @@ void cmd_tar(void)
|
|||||||
char **argl;
|
char **argl;
|
||||||
int argcl;
|
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"));
|
DEBUG(0,("tar <c|x>[IXbgan] <filename>\n"));
|
||||||
return;
|
return;
|
||||||
|
@ -628,8 +628,9 @@ int create_pipe_socket(char *dir, int dir_perms,
|
|||||||
|
|
||||||
/* The following definitions come from lib/util_str.c */
|
/* 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(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);
|
char **toktocliplist(int *ctok, char *sep);
|
||||||
int StrCaseCmp(const char *s, const char *t);
|
int StrCaseCmp(const char *s, const char *t);
|
||||||
int StrnCaseCmp(const char *s, const char *t, size_t n);
|
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);
|
int isspace_w( smb_ucs2_t val);
|
||||||
smb_ucs2_t toupper_w( smb_ucs2_t val );
|
smb_ucs2_t toupper_w( smb_ucs2_t val );
|
||||||
smb_ucs2_t tolower_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 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);
|
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);
|
BOOL strequal_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
|
||||||
|
@ -292,14 +292,14 @@ static BOOL get_cmd_args(char *line)
|
|||||||
cmd_argv = NULL;
|
cmd_argv = NULL;
|
||||||
|
|
||||||
/* get the first part of the command */
|
/* 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;
|
return False;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
add_chars_to_array(&cmd_argc, &cmd_argv, tok);
|
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);
|
add_chars_to_array(&cmd_argc, &cmd_argv, NULL);
|
||||||
|
|
||||||
|
@ -1658,7 +1658,7 @@ BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name)
|
|||||||
return False;
|
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);
|
fstrcpy(key_name, tmp);
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,6 @@
|
|||||||
|
|
||||||
extern int DEBUGLEVEL;
|
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
|
Get the next token from a string, return False if none found
|
||||||
handles double-quotes.
|
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)
|
BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
BOOL quoted;
|
BOOL quoted;
|
||||||
size_t len=1;
|
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 */
|
/* default to simple separators */
|
||||||
if (!sep) sep = " \t\n\r";
|
if (!sep) sep = " \t\n\r";
|
||||||
|
|
||||||
/* find the first non sep char */
|
/* find the first non sep char */
|
||||||
while(*s && strchr(sep,*s)) s++;
|
while (*s && strchr(sep,*s)) s++;
|
||||||
|
|
||||||
/* nothing left? */
|
/* nothing left? */
|
||||||
if (! *s) return(False);
|
if (! *s) return(False);
|
||||||
|
|
||||||
/* copy over the token */
|
/* 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 == '\"') {
|
||||||
if (*s == '\"') {
|
quoted = !quoted;
|
||||||
quoted = !quoted;
|
} else {
|
||||||
} else {
|
len++;
|
||||||
len++;
|
*buff++ = *s;
|
||||||
*buff++ = *s;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
*ptr = (*s) ? s+1 : s;
|
||||||
*ptr = (*s) ? s+1 : s;
|
*buff = 0;
|
||||||
*buff = 0;
|
|
||||||
last_ptr = *ptr;
|
return(True);
|
||||||
|
|
||||||
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.
|
Convert list of tokens to array; dependent on above routine.
|
||||||
Uses last_ptr from above - bit of a hack.
|
Uses last_ptr from above - bit of a hack.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
char **toktocliplist(int *ctok, char *sep)
|
char **toktocliplist(int *ctok, char *sep)
|
||||||
{
|
{
|
||||||
char *s=last_ptr;
|
char *s=last_ptr;
|
||||||
int ictok=0;
|
int ictok=0;
|
||||||
char **ret, **iret;
|
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? */
|
/* nothing left? */
|
||||||
if (!*s) return(NULL);
|
if (!*s) return(NULL);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ictok++;
|
ictok++;
|
||||||
while(*s && (!strchr(sep,*s))) s++;
|
while(*s && (!strchr(sep,*s))) s++;
|
||||||
while(*s && strchr(sep,*s)) *s++=0;
|
while(*s && strchr(sep,*s)) *s++=0;
|
||||||
} while(*s);
|
} 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;
|
return ret;
|
||||||
s=last_ptr;
|
|
||||||
|
|
||||||
if (!(ret=iret=malloc(ictok*sizeof(char *)))) return NULL;
|
|
||||||
|
|
||||||
while(ictok--) {
|
|
||||||
*iret++=s;
|
|
||||||
while(*s++);
|
|
||||||
while(!*s) s++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1169,133 +1169,6 @@ smb_ucs2_t tolower_w( smb_ucs2_t val )
|
|||||||
return map_table_lower(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.
|
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;
|
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 */
|
/* This is used to prevent lots of mallocs of size 2 */
|
||||||
static smb_ucs2_t *null_string = NULL;
|
static smb_ucs2_t *null_string = NULL;
|
||||||
|
@ -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);
|
memset(cli->inbuf,'\0',smb_size);
|
||||||
|
|
||||||
if (size > 0xFFFF)
|
if (size > 0xFFFF)
|
||||||
set_message(cli->outbuf,14,size,True);
|
set_message(cli->outbuf,14,0,True);
|
||||||
else
|
else
|
||||||
set_message(cli->outbuf,12,size,True);
|
set_message(cli->outbuf,12,0,True);
|
||||||
|
|
||||||
CVAL(cli->outbuf,smb_com) = SMBwriteX;
|
CVAL(cli->outbuf,smb_com) = SMBwriteX;
|
||||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
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);
|
p = smb_base(cli->outbuf) + SVAL(cli->outbuf,smb_vwv11);
|
||||||
memcpy(p, buf, size);
|
memcpy(p, buf, size);
|
||||||
|
cli_setup_bcc(cli, p+size);
|
||||||
|
|
||||||
SSVAL(cli->outbuf,smb_mid,cli->mid + i);
|
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->outbuf,'\0',smb_size);
|
||||||
memset(cli->inbuf,'\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;
|
CVAL(cli->outbuf,smb_com) = SMBwrite;
|
||||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
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 = smb_buf(cli->outbuf);
|
||||||
*p++ = 1;
|
*p++ = 1;
|
||||||
SSVAL(p, 0, size);
|
SSVAL(p, 0, size); p += 2;
|
||||||
memcpy(p+2, buf, size);
|
memcpy(p, buf, size); p += size;
|
||||||
|
|
||||||
|
cli_setup_bcc(cli, p);
|
||||||
|
|
||||||
cli_send_smb(cli);
|
cli_send_smb(cli);
|
||||||
if (!cli_receive_smb(cli)) {
|
if (!cli_receive_smb(cli)) {
|
||||||
|
@ -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
|
lib/util_str.c as I really don't want to have to link in any other
|
||||||
objects if I can possibly avoid it. */
|
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;
|
char *s;
|
||||||
BOOL quoted;
|
BOOL quoted;
|
||||||
size_t len=1;
|
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 */
|
/* default to simple separators */
|
||||||
if (!sep) sep = " \t\n\r";
|
if (!sep) sep = " \t\n\r";
|
||||||
|
|
||||||
/* find the first non sep char */
|
/* find the first non sep char */
|
||||||
while(*s && strchr(sep,*s)) s++;
|
while (*s && strchr(sep,*s)) s++;
|
||||||
|
|
||||||
/* nothing left? */
|
/* nothing left? */
|
||||||
if (! *s) return(False);
|
if (! *s) return(False);
|
||||||
|
|
||||||
/* copy over the token */
|
/* copy over the token */
|
||||||
for (quoted = False;
|
for (quoted = False; len < bufsize && *s && (quoted || !strchr(sep,*s)); s++) {
|
||||||
len < bufsize && *s && (quoted || !strchr(sep,*s));
|
|
||||||
s++) {
|
|
||||||
|
|
||||||
if (*s == '\"') {
|
if (*s == '\"') {
|
||||||
quoted = !quoted;
|
quoted = !quoted;
|
||||||
} else {
|
} else {
|
||||||
@ -107,14 +101,14 @@ BOOL next_token(char **ptr, char *buff, char *sep, size_t bufsize)
|
|||||||
*buff++ = *s;
|
*buff++ = *s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*ptr = (*s) ? s+1 : s;
|
*ptr = (*s) ? s+1 : s;
|
||||||
*buff = 0;
|
*buff = 0;
|
||||||
last_ptr = *ptr;
|
|
||||||
|
|
||||||
return(True);
|
return(True);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Fill a pwent structure from a winbindd_response structure. We use
|
/* 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.
|
the static data passed to us by libc to put strings and stuff in.
|
||||||
Return NSS_STATUS_TRYAGAIN if we run out of memory. */
|
Return NSS_STATUS_TRYAGAIN if we run out of memory. */
|
||||||
|
@ -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));
|
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");
|
fprintf(out_hnd, "regenum <key_name>\n");
|
||||||
return;
|
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));
|
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");
|
fprintf(out_hnd, "regquery key_name\n");
|
||||||
return;
|
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));
|
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");
|
fprintf(out_hnd, "regcreate <val_name> <val_type> <val>\n");
|
||||||
return;
|
return;
|
||||||
@ -363,7 +363,7 @@ void cmd_reg_create_val(struct client_info *info)
|
|||||||
return;
|
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");
|
fprintf(out_hnd, "regcreate <val_name> <val_type (1|4)> <val>\n");
|
||||||
return;
|
return;
|
||||||
@ -377,7 +377,7 @@ void cmd_reg_create_val(struct client_info *info)
|
|||||||
return;
|
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");
|
fprintf(out_hnd, "regcreate <val_name> <val_type (1|4)> <val>\n");
|
||||||
return;
|
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));
|
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");
|
fprintf(out_hnd, "regdelete <val_name>\n");
|
||||||
return;
|
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));
|
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");
|
fprintf(out_hnd, "regdeletekey <key_name>\n");
|
||||||
return;
|
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));
|
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");
|
fprintf(out_hnd, "regcreate <key_name> [key_class]\n");
|
||||||
return;
|
return;
|
||||||
@ -654,7 +654,7 @@ void cmd_reg_create_key(struct client_info *info)
|
|||||||
return;
|
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));
|
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));
|
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");
|
fprintf(out_hnd, "reggetsec <key_name>\n");
|
||||||
return;
|
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));
|
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");
|
fprintf(out_hnd, "reggetsec <key_name>\n");
|
||||||
return;
|
return;
|
||||||
|
@ -55,7 +55,7 @@ void cmd_wks_query_info(struct client_info *info)
|
|||||||
fstrcat(dest_wks, info->dest_host);
|
fstrcat(dest_wks, info->dest_host);
|
||||||
strupper(dest_wks);
|
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);
|
info_level = (uint32)strtol(tmp, (char**)NULL, 10);
|
||||||
}
|
}
|
||||||
|
@ -358,13 +358,13 @@ static uint32 do_cmd(struct cli_state *cli, struct cmd_set *cmd_entry, char *cmd
|
|||||||
pstring buf;
|
pstring buf;
|
||||||
int argc = 1, i;
|
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
|
/* Count number of arguments first time through the loop then
|
||||||
allocate memory and strdup them. */
|
allocate memory and strdup them. */
|
||||||
|
|
||||||
again:
|
again:
|
||||||
while(next_token(NULL, buf, " ", sizeof(buf))) {
|
while(next_token_nr(NULL, buf, " ", sizeof(buf))) {
|
||||||
if (argv) {
|
if (argv) {
|
||||||
argv[argc] = strdup(buf);
|
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;
|
p = cmd;
|
||||||
next_token(&p, buf, " ", sizeof(buf));
|
next_token_nr(&p, buf, " ", sizeof(buf));
|
||||||
argv[0] = strdup(buf);
|
argv[0] = strdup(buf);
|
||||||
argc = 1;
|
argc = 1;
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ static uint32 process_cmd(struct cli_state *cli, char *cmd)
|
|||||||
if (cmd[strlen(cmd) - 1] == '\n')
|
if (cmd[strlen(cmd) - 1] == '\n')
|
||||||
cmd[strlen(cmd) - 1] = '\0';
|
cmd[strlen(cmd) - 1] = '\0';
|
||||||
|
|
||||||
if (!next_token(&p, buf, " ", sizeof(buf))) {
|
if (!next_token_nr(&p, buf, " ", sizeof(buf))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ static BOOL process_lockread(blocking_lock_record *blr)
|
|||||||
char *outbuf = OutBuffer;
|
char *outbuf = OutBuffer;
|
||||||
char *inbuf = blr->inbuf;
|
char *inbuf = blr->inbuf;
|
||||||
ssize_t nread = -1;
|
ssize_t nread = -1;
|
||||||
char *data;
|
char *data, *p;
|
||||||
int outsize = 0;
|
int outsize = 0;
|
||||||
SMB_OFF_T startpos;
|
SMB_OFF_T startpos;
|
||||||
size_t numtoread;
|
size_t numtoread;
|
||||||
@ -309,12 +309,15 @@ static BOOL process_lockread(blocking_lock_record *blr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
construct_reply_common(inbuf, outbuf);
|
construct_reply_common(inbuf, outbuf);
|
||||||
outsize = set_message(outbuf,5,3,True);
|
outsize = set_message(outbuf,5,0,True);
|
||||||
|
|
||||||
outsize += nread;
|
outsize += nread;
|
||||||
SSVAL(outbuf,smb_vwv0,nread);
|
SSVAL(outbuf,smb_vwv0,nread);
|
||||||
SSVAL(outbuf,smb_vwv5,nread+3);
|
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",
|
DEBUG(3, ( "process_lockread file = %s, fnum=%d num=%d nread=%d\n",
|
||||||
fsp->fsp_name, fsp->fnum, (int)numtoread, (int)nread ) );
|
fsp->fsp_name, fsp->fnum, (int)numtoread, (int)nread ) );
|
||||||
|
@ -266,12 +266,12 @@ static BOOL parse_ace(SEC_ACE *ace, char *str)
|
|||||||
|
|
||||||
/* Only numeric form accepted for flags at present */
|
/* 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))) {
|
sscanf(tok, "%i", &aflags))) {
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!next_token(NULL, tok, "/", sizeof(fstring))) {
|
if (!next_token(&p, tok, "/", sizeof(fstring))) {
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user