diff options
author | Guillem Jover <guillem@debian.org> | 2009-02-27 07:00:17 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2009-02-27 07:20:44 +0200 |
commit | 53b1f8871fea748e0360bf9183735ab54f7a1f64 (patch) | |
tree | 6408646dfd073c670595d6a0acf2590b0b29b1df /lib | |
parent | 22408d0c3dac33a396a451e18f1e8860793928d3 (diff) | |
download | dpkg-53b1f8871fea748e0360bf9183735ab54f7a1f64.tar.gz |
libdpkg: Add support for ustar long names using the prefix field
The ustar format has been supported up to now except for the long names
which use the prefix field that needs to be prepended to the name field
if non empty.
Closes: #474092
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tarfn.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/tarfn.c b/lib/tarfn.c index ecb5acb21..8e9049136 100644 --- a/lib/tarfn.c +++ b/lib/tarfn.c @@ -74,6 +74,28 @@ StoC(const char *s, int size) return str; } +/* FIXME: Rewrite using varbuf, once it supports the needed functionality. */ +static char * +get_prefix_name(TarHeader *h) +{ + char *prefix, *name, *s; + + /* The size is not going to be bigger than that. */ + s = m_malloc(257); + + prefix = StoC(h->Prefix, sizeof(h->Prefix)); + name = StoC(h->Name, sizeof(h->Name)); + + strcpy(s, prefix); + strcat(s, "/"); + strcat(s, name); + + free(prefix); + free(name); + + return s; +} + static int DecodeTarHeader(char * block, TarInfo * d) { @@ -97,8 +119,9 @@ DecodeTarHeader(char * block, TarInfo * d) if ( *h->GroupName ) group = getgrnam(h->GroupName); + /* Concatenate prefix and name to support ustar style long names. */ if (d->format == tar_format_ustar && h->Prefix[0] != '\0') - abort(); + d->Name = get_prefix_name(h); else d->Name = StoC(h->Name, sizeof(h->Name)); d->LinkName = StoC(h->LinkName, sizeof(h->LinkName)); |