[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] Re: bugs in dirname module - tar portion
From: |
Eric Blake |
Subject: |
[Bug-tar] Re: bugs in dirname module - tar portion |
Date: |
Sat, 26 Nov 2005 07:51:10 -0700 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
This is my patch to tar/paxutils to match the dirname module updates
thread on gnulib:
http://lists.gnu.org/archive/html/bug-gnulib/2005-11/msg00071.html
It should be applied once the gnulib patch is applied, although you may
want to address the memory leak in xheader_format_name sooner.
paxutils/ChangeLog:
2005-11-26 Eric Blake <address@hidden>
* lib/rtapelib.c (rmt_open__): Use new last_component from gnulib.
* paxlib/rtape.c (rmt_open): Likewise.
tar/ChangeLog:
2005-11-26 Eric Blake <address@hidden>
* .cvsignore: Ignore .bootstrap.
* lib/.cvsignore: Ignore xstrndup.[ch].
The gnulib dirname module has changed semantics.
* src/extract.c (create_placeholder_file): Use new last_component
from gnulib.
* src/xheader.c (xheader_format_name): Fix memory leak in usage of
dir_name and new behavior of base_name.
- --
Life is short - so eat dessert first!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDiHZe84KuGfSFAYARArAfAKCGxPmEZgQ5av1YurHw8fW7eeMVZwCeMR5A
z6Ij+eVOhsSH9AwH625nmdw=
=HQD7
-----END PGP SIGNATURE-----
Index: .cvsignore
===================================================================
RCS file: /cvsroot/tar/tar/.cvsignore,v
retrieving revision 1.5
diff -u -p -r1.5 .cvsignore
--- .cvsignore 4 Apr 2005 18:46:00 -0000 1.5
+++ .cvsignore 26 Nov 2005 14:46:04 -0000
@@ -1,6 +1,7 @@
*.bz2
*.gz
*.tar
+.bootstrap
ABOUT-NLS
COPYING
INSTALL
Index: lib/.cvsignore
===================================================================
RCS file: /cvsroot/tar/tar/lib/.cvsignore,v
retrieving revision 1.27
diff -u -p -r1.27 .cvsignore
--- lib/.cvsignore 11 Nov 2005 12:15:46 -0000 1.27
+++ lib/.cvsignore 26 Nov 2005 14:46:10 -0000
@@ -189,6 +189,8 @@ xgetcwd.c
xgetcwd.h
xmalloc.c
xsize.h
+xstrndup.c
+xstrndup.h
xstrtol.c
xstrtol.h
xstrtoul.c
Index: src/extract.c
===================================================================
RCS file: /cvsroot/tar/tar/src/extract.c,v
retrieving revision 1.84
diff -u -p -r1.84 extract.c
--- src/extract.c 9 Nov 2005 13:08:43 -0000 1.84
+++ src/extract.c 26 Nov 2005 14:46:10 -0000
@@ -855,7 +855,7 @@ create_placeholder_file (char *file_name
if (h && ! h->after_links
&& strncmp (file_name, h->file_name, h->file_name_len) == 0
&& ISSLASH (file_name[h->file_name_len])
- && (base_name (file_name) == file_name + h->file_name_len + 1))
+ && (last_component (file_name) == file_name + h->file_name_len + 1))
{
do
{
Index: src/xheader.c
===================================================================
RCS file: /cvsroot/tar/tar/src/xheader.c,v
retrieving revision 1.37
diff -u -p -r1.37 xheader.c
--- src/xheader.c 11 Nov 2005 00:26:09 -0000 1.37
+++ src/xheader.c 26 Nov 2005 14:46:11 -0000
@@ -236,6 +236,7 @@ xheader_format_name (struct tar_stat_inf
char *q;
const char *p;
char *dir = NULL;
+ char *safer_dir = NULL;
char *base = NULL;
char pidbuf[UINTMAX_STRSIZE_BOUND];
char const *pptr;
@@ -253,16 +254,19 @@ xheader_format_name (struct tar_stat_inf
case 'd':
if (st)
{
- dir = safer_name_suffix (dir_name (st->orig_file_name),
- false, absolute_names_option);
- len += strlen (dir) - 2;
+ if (! dir)
+ dir = dir_name (st->orig_file_name);
+ safer_dir = safer_name_suffix (dir, false,
+ absolute_names_option);
+ len += strlen (safer_dir) - 2;
}
break;
case 'f':
if (st)
{
- base = base_name (st->orig_file_name);
+ if (! base)
+ base = base_name (st->orig_file_name);
len += strlen (base) - 2;
}
break;
@@ -293,8 +297,8 @@ xheader_format_name (struct tar_stat_inf
break;
case 'd':
- if (dir)
- q = stpcpy (q, dir);
+ if (safer_dir)
+ q = stpcpy (q, safer_dir);
p += 2;
break;
@@ -332,6 +336,9 @@ xheader_format_name (struct tar_stat_inf
while (q > buf && ISSLASH (q[-1]))
q--;
*q = 0;
+
+ free (dir);
+ free (base);
return buf;
}
Index: paxutils/lib/rtapelib.c
===================================================================
RCS file: /cvsroot/paxutils/paxutils/lib/rtapelib.c,v
retrieving revision 1.2
diff -u -p -r1.2 rtapelib.c
--- paxutils/lib/rtapelib.c 15 May 2005 06:34:49 -0000 1.2
+++ paxutils/lib/rtapelib.c 26 Nov 2005 14:46:15 -0000
@@ -1,6 +1,6 @@
/* Functions for communicating with a remote tape drive.
- Copyright 1988, 1992, 1994, 1996, 1997, 1999, 2000, 2001, 2004 Free
+ Copyright 1988, 1992, 1994, 1996, 1997, 1999, 2000, 2001, 2004, 2005 Free
Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -461,7 +461,7 @@ rmt_open__ (const char *file_name, int o
return -1;
#endif
}
- remote_shell_basename = base_name (remote_shell);
+ remote_shell_basename = last_component (remote_shell);
/* Set up the pipes for the `rsh' command, and fork. */
Index: paxutils/paxlib/rtape.c
===================================================================
RCS file: /cvsroot/paxutils/paxutils/paxlib/rtape.c,v
retrieving revision 1.2
diff -u -p -r1.2 rtape.c
--- paxutils/paxlib/rtape.c 15 May 2005 06:34:49 -0000 1.2
+++ paxutils/paxlib/rtape.c 26 Nov 2005 14:46:15 -0000
@@ -468,7 +468,7 @@ rmt_open (const char *file_name, int ope
return -1;
#endif
}
- remote_shell_basename = base_name (remote_shell);
+ remote_shell_basename = last_component (remote_shell);
/* Set up the pipes for the `rsh' command, and fork. */
@@ -758,4 +758,3 @@ rmt_ioctl (int handle, int operation, ch
}
}
-
- [Bug-tar] Re: bugs in dirname module - tar portion,
Eric Blake <=