On Wed, Sep 15, 2004 at 05:20:56PM -0400, Luis Benvenutto
wrote:> Hi all,
> My old and stable backup script don't work anymore.
> It's based on smbclient's tar command using crX parameters for
creating
> archive, excluding files based on basic regular expressions.
> The box is running Fedora core 2, fully updated:
> kernel-2.6.8-1.521
> samba-common-3.0.7-2.FC2
> samba-client-3.0.7-2.FC2
> The error is easily reproducible:
>
> smbclient //ntpdc/share -A credfile \
> -c "tar crX ntpdc.share.tar *.tmp"
>
> exits with error 139. Output is:
>
> tar_re_search set
> directory \subdir\
> Segmentation fault
>
> Is regular expression exclusion broken?
Thanks - I've found the problem. Here is the patch (attached). I've
committed this to 3.0.x and HEAD. It'll be in the next release.
Thanks a *lot*,
Jeremy.
-------------- next part --------------
Index: lib/util_str.c
==================================================================---
lib/util_str.c (revision 2353)
+++ lib/util_str.c (working copy)
@@ -134,17 +134,20 @@
*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;
- while(*s++)
- ;
- while(!*s)
- s++;
+ if (ictok > 0) {
+ while(*s++)
+ ;
+ while(!*s)
+ s++;
+ }
}
+ ret[*ctok] = NULL;
return ret;
}
Index: client/clitar.c
==================================================================---
client/clitar.c (revision 2353)
+++ client/clitar.c (working copy)
@@ -1345,8 +1345,9 @@
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 @@
if (!tar_parseargs(argcl, argl, buf, 0))
return 1;
+ ret = process_tar();
SAFE_FREE(argl);
- return process_tar();
+ return ret;
}
/****************************************************************************