Your message dated Sun, 05 Oct 2014 15:45:42 +0200
with message-id <27719449.ly5BLVfHjU@johansson>
has caused the report #763119,
regarding misinterprets old-style GNU headers
to be marked as having been forwarded to the upstream software
author(s) [email protected]
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
763119: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763119
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
On Monday, 29 September 2014 01.50.51, Steinar H. Gunderson wrote:
> > On Sun, Sep 28, 2014 at 01:49:52AM +0200, Steinar H. Gunderson wrote:
> > The old-style GNU header format (used before GNU tar 1.12) looks very much
> > like the POSIX format, except that there is no “prefix” field, and those
> > bytes are used for other fields, such as mtime, ctime, multi-volume
> > support
> > and so on.
> >
> > One would think that this format is now long irrelevant, but
> > unfortunately,
> > tar automatically switches to these headers when making incremental
> > archives
> > (whether old-style or new-style incremental archives). Thus, when libtar
> > looks at such an archive, it will misinterpret these headers as a prefix
> > field, and extract things such as “12411637142/./foo.c” and the likes
> > (unless they are above 100 bytes, in which case the GNU-style name takes
> > over!).
> >
> > I've attached a simple patch to fix this; it doesn't give access to all
> > the
> > other fields, but at least it fixes th_get_pathname() (which seems to be
> > pretty much the only place the prefix field is actually interpreted) so
> > that it does not return these bogus paths.
>
> I'm sorry, this wasn't well enough tested; it only works with -H oldgnu,
> not --incremental (which was what I intended to fix), so it's all wrong,
> and the logic is inverted to boot. This one should be much better;
> tested with a regular tarball, -H oldgnu and -g.
Any comments on this?
--
Magnus Holmgren [email protected]
Debian Developer
Index: libtar-1.2.20/lib/decode.c
===================================================================
--- libtar-1.2.20.orig/lib/decode.c
+++ libtar-1.2.20/lib/decode.c
@@ -69,7 +69,14 @@ th_get_pathname(TAR *t)
return NULL;
}
- if (t->th_buf.prefix[0] == '\0')
+ /*
+ * Old GNU headers (also used by newer GNU tar when doing incremental
+ * dumps) use the POSIX prefix field for many other things, such as
+ * mtime and ctime. New-style GNU headers don't, but also don't use the
+ * POSIX prefix field. Thus, only honor the prefix field if the archive
+ * is actually a POSIX archive. This is the same logic as GNU tar uses.
+ */
+ if (strcmp(t->th_buf.magic, TMAGIC) != 0 || t->th_buf.prefix[0] == '\0')
{
sprintf(t->th_pathname, "%.100s", t->th_buf.name);
}
--- End Message ---