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

r2361: Fix the appalling toktocliplist() fn. Bug found by Luis Benvenutto.

Jeremy.
This commit is contained in:
Jeremy Allison 2004-09-15 22:49:23 +00:00 committed by Gerald (Jerry) Carter
parent d6b26f9db7
commit d434d8e2b4
2 changed files with 13 additions and 8 deletions

View File

@ -1345,8 +1345,9 @@ Principal command for creating / extracting
int cmd_tar(void)
{
fstring buf;
char **argl;
int argcl;
char **argl = NULL;
int argcl = 0;
int ret;
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
DEBUG(0,("tar <c|x>[IXbgan] <filename>\n"));
@ -1357,8 +1358,9 @@ int cmd_tar(void)
if (!tar_parseargs(argcl, argl, buf, 0))
return 1;
ret = process_tar();
SAFE_FREE(argl);
return process_tar();
return ret;
}
/****************************************************************************

View File

@ -134,17 +134,20 @@ char **toktocliplist(int *ctok, const char *sep)
*ctok=ictok;
s=(char *)last_ptr;
if (!(ret=iret=malloc(ictok*sizeof(char *))))
if (!(ret=iret=malloc((ictok+1)*sizeof(char *))))
return NULL;
while(ictok--) {
*iret++=s;
if (ictok > 0) {
while(*s++)
;
while(!*s)
s++;
}
}
ret[*ctok] = NULL;
return ret;
}