dpkg and long file name directory components
When a file name with the directory component is larger than 100
bytes, GNU tar uses a GNU extension to encode it. The code in
lib/tarfn.c that decodes tar files is unable to decode the extension
and fails.
To repeat this, try creating a package consisting of a file named,
say,
foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/.
`dpkg -b' passes, but not `dpkg -i' -- it complains about a "corrupted
tarfile". The patch below fixes tarfn.c to understand the extension.
The patch needs more tweaking to accept path names longer than 512
bytes, but the general concept is there.
If this is not the correct address for mailing patches, feel free to
relay it further.
diff -ru dpkg-1.4.0.8-cn/include/tarfn.h dpkg-1.4.0.8-cn-patched/include/tarfn.h
--- dpkg-1.4.0.8-cn/include/tarfn.h Sun Jan 14 18:56:26 1996
+++ dpkg-1.4.0.8-cn-patched/include/tarfn.h Sat Oct 24 02:06:47 1998
@@ -20,7 +20,9 @@
CharacterDevice = '3',
BlockDevice = '4',
Directory = '5',
- FIFO = '6'
+ FIFO = '6',
+ LongLink = 'K',
+ LongName = 'L'
};
typedef enum TarFileType TarFileType;
diff -ru dpkg-1.4.0.8-cn/lib/tarfn.c dpkg-1.4.0.8-cn-patched/lib/tarfn.c
--- dpkg-1.4.0.8-cn/lib/tarfn.c Thu Apr 16 11:11:11 1998
+++ dpkg-1.4.0.8-cn-patched/lib/tarfn.c Sat Oct 24 02:21:11 1998
@@ -104,6 +104,8 @@
{
int status;
char buffer[512];
+ char realname[512], reallinkname[512];
+ int longp = 0;
TarInfo h;
h.UserData = userData;
@@ -124,9 +126,25 @@
return -1; /* Bad header data */
}
+ if (longp & 0x1)
+ h.Name = realname;
+ if (longp & 0x2)
+ h.LinkName = reallinkname;
+
nameLength = strlen(h.Name);
switch ( h.Type ) {
+ case LongName:
+ case LongLink:
+ {
+ char *op = (h.Type == LongName ? realname : reallinkname);
+ if ((status = functions->Read(userData, op, 512))
+ != 512)
+ return status;
+ op[h.Size] = '\0';
+ longp |= (h.Type == LongName ? 1 : 2);
+ continue;
+ }
case NormalFile0:
case NormalFile1:
/* Compatibility with pre-ANSI ustar */
@@ -154,6 +172,7 @@
errno = 0; /* Indicates broken tarfile */
return -1; /* Bad header field */
}
+ longp = 0;
if ( status != 0 )
return status; /* Pass on status from coroutine */
}
--
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
`VI' - An editor used by those heretics that don't subscribe to
the Emacs religion.
Reply to: