[BusyBox] seek_sub_file in unarchive.c broken?

Stefan Soucek ssoucek at coactive.com
Fri Sep 21 12:12:45 UTC 2001


I have discovered a strange behavior with dpkg. When the package file
contains any files (alphabetically) before the control file in the control
section, dpkg reports "cannot extract control file". It seems to me that
the current implementation of seek_sub_file() in libbb/unarchive.c has a

It tries to optimize the pipe read by skipping 'count' characters using
lseek on the pipe. I am not sure what happens exactly, but it looks like
lseek positions the stream somewhere further on even when it gets
ESPIPE. Then the for loop consumes another 'count' characters from the
pipe, which screws up the intended positioning.

As a temporary fix, I commented out the lseek stuff, and it works file


RCS file: /prj/cvs/busybox/libbb/unarchive.c,v
retrieving revision
retrieving revision 1.6
diff -u -b -B -w -p -r1.1.1.5 -r1.6
--- unarchive.c 2001/09/14 01:12:55
+++ unarchive.c 2001/09/14 18:26:00     1.6
@@ -43,11 +43,12 @@ void seek_sub_file(FILE *src_stream, con
        int i;
        /* Try to fseek as faster */
+       /* StS - fseek seems to break this when it is SIGPIPED. Then the
for loop
+        * reads another 'count' bytes. */
        archive_offset += count;
-       if (fseek(src_stream, count, SEEK_CUR) != 0 && errno == ESPIPE) {
+       /*if (fseek(src_stream, count, SEEK_CUR) != 0 && errno ==
        for (i = 0; i < count; i++) {
-               }

More information about the busybox mailing list