[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#287152: dpkg does not handle directories without trailing slash in tar

Package: dpkg
Version: 1.9.21
Severity: normal
Tags: patch

[Cc readers: scroll down]

the FreeBSD linux_base-debian port unpacks and repacks one of the
base .deb's to brandelf one binary. Further down the road, stuff
breaks. Investigation showed that the new FreeBSD tar leaves off
the trailing slashes on directory names. dpkg removes the last
character from any directory name without checking, turning
'/lib' into '/li', etcetera.

A simple patch:
diff -urN /tmp/dpkg-1.9.21/lib/tarfn.c dpkg-1.9.21/lib/tarfn.c
--- /tmp/dpkg-1.9.21/lib/tarfn.c        Mon Apr 23 13:29:30 2001
+++ dpkg-1.9.21/lib/tarfn.c     Sat Dec 25 00:37:17 2004
@@ -156,7 +156,9 @@
                        /* Else, Fall Through */
                case Directory:
-                       h.Name[nameLength - 1] = '\0';
+                       if ( h.Name[nameLength - 1] == '/' ) {
+                               h.Name[nameLength - 1] = '\0';
+                       }
                        status = (*functions->MakeDirectory)(&h);
                case HardLink:

Some Google use after making this patch turned up this thread:
(this is one thread). In this thread basically the same fix is
proposed. I am reporting this as a bug through the right channels
to make sure that a fix gets in.

Right now, linux_base-debian in FreeBSD is marked for deletion due
february 2005 because of this exact bug, which would be a shame.

[system information below is incorrect; the dpkg binary involved
 is a FreeBSD native compile from the FreeBSD ports tree, version
 1.9.21_2 (_2 is the port revision which has no patches relevant
 to this problem].

[to the Cc: reader, kris@freebsd.org: the port installs and builds
 without trouble if dpkg is patched as described above. Either
 an upstream fix plus bumping the dpkg version in the port, or just
 putting this patch in the portstree itself, would allow
 linux_base-debian to lose the BROKEN mark]

-- System Information:
Debian Release: 3.1
Architecture: Linux fanta.home.dataloss.nl 2.4.2 FreeBSD 5.3-RELEASE
#0: Sat Nov
 13 15:12:47 CET 2004 i686 GNU/Linux
Kernel: Linux 2.4.2
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Reply to: