diff options
author | Jeremy Allison <jra@samba.org> | 2003-09-02 23:58:39 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-09-02 23:58:39 +0000 |
commit | e2b73477e772ac2f527719df0d3d64c67649bb1c (patch) | |
tree | 8292cf7fdc47faf3d8747ab2b773a298418114bf /source/client | |
parent | 01096554110ba243566003a45f88dbaeb513fc73 (diff) | |
download | samba-e2b73477e772ac2f527719df0d3d64c67649bb1c.tar.gz samba-e2b73477e772ac2f527719df0d3d64c67649bb1c.tar.xz samba-e2b73477e772ac2f527719df0d3d64c67649bb1c.zip |
Proposed patch for #308. Needs testing.
Jeremy
Diffstat (limited to 'source/client')
-rw-r--r-- | source/client/clitar.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/source/client/clitar.c b/source/client/clitar.c index f7a292dbbfe..b01de5b8e70 100644 --- a/source/client/clitar.c +++ b/source/client/clitar.c @@ -122,7 +122,7 @@ static void writetarheader(int f, const char *aname, SMB_BIG_UINT size, time_t static void do_atar(char *rname,char *lname,file_info *finfo1); static void do_tar(file_info *finfo); static void oct_it(SMB_BIG_UINT value, int ndgs, char *p); -static void fixtarname(char *tptr, const char *fp, int l); +static void fixtarname(char *tptr, const char *fp, size_t l); static int dotarbuf(int f, char *b, int n); static void dozerobuf(int f, int n); static void dotareof(int f); @@ -171,7 +171,10 @@ static void writetarheader(int f, const char *aname, SMB_BIG_UINT size, time_t m memset(hb.dummy, 0, sizeof(hb.dummy)); l=strlen(aname); - if (l >= NAMSIZ - 1) { + /* We will be prepending a '.' in fixtarheader so use +2 to + * take care of the . and terminating zero. JRA. + */ + if (l+2 >= NAMSIZ) { /* write a GNU tar style long header */ char *b; b = (char *)malloc(l+TBLOCK+100); @@ -181,15 +184,14 @@ static void writetarheader(int f, const char *aname, SMB_BIG_UINT size, time_t m } writetarheader(f, "/./@LongLink", l+2, 0, " 0 \0", 'L'); memset(b, 0, l+TBLOCK+100); - fixtarname(b, aname, l); + fixtarname(b, aname, l+2); i = strlen(b)+1; DEBUG(5, ("File name in tar file: %s, size=%d, \n", b, (int)strlen(b))); dotarbuf(f, b, TBLOCK*(((i-1)/TBLOCK)+1)); SAFE_FREE(b); } - /* use l + 1 to do the null too */ - fixtarname(hb.dbuf.name, aname, (l >= NAMSIZ) ? NAMSIZ : l + 1); + fixtarname(hb.dbuf.name, aname, (l+2 >= NAMSIZ) ? NAMSIZ : l + 2); if (lowercase) strlower_m(hb.dbuf.name); @@ -419,13 +421,14 @@ static void dotareof(int f) (Un)mangle DOS pathname, make nonabsolute ****************************************************************************/ -static void fixtarname(char *tptr, const char *fp, int l) +static void fixtarname(char *tptr, const char *fp, size_t l) { /* add a '.' to start of file name, convert from ugly dos \'s in path * to lovely unix /'s :-} */ *tptr++='.'; + l--; - safe_strcpy(tptr, fp, l); + StrnCpy(tptr, fp, l-1); string_replace(tptr, '\\', '/'); } |