Explorar el Código

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
Guillem Jover hace 17 años
padre
commit
53b1f8871f
Se han modificado 4 ficheros con 35 adiciones y 3 borrados
  1. 7 0
      ChangeLog
  2. 1 0
      debian/changelog
  3. 24 1
      lib/tarfn.c
  4. 3 2
      man/deb.5

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+2009-02-27  Guillem Jover  <guillem@debian.org>
+
+	* lib/tarfn.c (get_prefix_name): New function.
+	(DecodeTarHeader): On tar_format_ustar and if Prefix is not empty
+	call get_prefix_name instead of aborting.
+	* man/deb.5: Document that ustar format is now properly supported.
+
 2009-02-27  Guillem Jover  <guillem@debian.org>
 
 	* lib/tarfn.h (enum tar_format): New type.

+ 1 - 0
debian/changelog

@@ -62,6 +62,7 @@ dpkg (1.15.0) UNRELEASED; urgency=low
     IO scheduling class and priority. Closes: #443535
     Thanks to Chris Coulson <chrisccoulson@googlemail.com>.
   * Add tar format detection support to the internal extractor.
+  * Add support for ustar long names using the prefix field. Closes: #474092
 
   [ Raphael Hertzog ]
   * Enhance dpkg-shlibdeps's error message when a library can't be found to

+ 24 - 1
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));

+ 3 - 2
man/deb.5

@@ -1,4 +1,4 @@
-.TH deb 5 "2009-02-06" "Debian Project" "Debian"
+.TH deb 5 "2009-02-27" "Debian Project" "Debian"
 .SH NAME
 deb \- Debian binary package format
 .SH SYNOPSIS
@@ -22,7 +22,8 @@ The file names might contain a trailing slash.
 .PP
 The \fBtar\fP archives currently allowed are, the old-style (v7) format,
 the pre-POSIX ustar format, a subset of the GNU format (only the new
-style long pathnames and long linknames, supported since dpkg 1.4.1.17).
+style long pathnames and long linknames, supported since dpkg 1.4.1.17),
+and the POSIX ustar format (long names supported since dpkg 1.15.0).
 Unrecognized tar typeflags are considered an error.
 .PP
 The first member is named