Explorar el Código

dpkg-deb: Do not accept deb packages with data and control members swapped

This is not allowed by the format defined in deb(5), but dpkg-deb has
been very lenient all this time. Enforce the correct format by erroring
out in case of misplaced members.
Guillem Jover hace 13 años
padre
commit
547dca4c3f
Se han modificado 2 ficheros con 7 adiciones y 1 borrados
  1. 1 0
      debian/changelog
  2. 6 1
      dpkg-deb/extract.c

+ 1 - 0
debian/changelog

@@ -10,6 +10,7 @@ dpkg (1.17.2) UNRELEASED; urgency=low
     does not ship the overlapping paths any more.
   * Automatically prepend needed spaces for continuation --force-help lines.
   * Be more precise on deb format errors with data member in dpkg-deb.
+  * Do not allow deb packages with control and data members swapped.
 
  -- Guillem Jover <guillem@debian.org>  Sun, 28 Jul 2013 15:06:29 +0200
 

+ 6 - 1
dpkg-deb/extract.c

@@ -120,7 +120,7 @@ extracthalf(const char *debar, const char *dir,
   int arfd;
   struct stat stab;
   char nlc;
-  int adminmember;
+  int adminmember = -1;
   bool header_done;
   enum compressor_type decompressor = compressor_type_gzip;
 
@@ -181,6 +181,11 @@ extracthalf(const char *debar, const char *dir,
 	if (strncmp(arh.ar_name, ADMINMEMBER, sizeof(arh.ar_name)) == 0)
 	  adminmember = 1;
 	else {
+          if (adminmember != 1)
+            ohshit(_("archive '%s' has premature member '%.*s' before '%s', "
+                     "giving up"),
+                   debar, (int)sizeof(arh.ar_name), arh.ar_name, ADMINMEMBER);
+
 	  if (strncmp(arh.ar_name, DATAMEMBER, strlen(DATAMEMBER)) == 0) {
 	    const char *extension = arh.ar_name + strlen(DATAMEMBER);