*/
do {
if (membuf[iobuf.in_pos] != 0) {
+ /* There is more data, but is it XZ data?
+ * Example: dpkg-deb -f busybox_1.30.1-4_amd64.deb
+ * reads control.tar.xz "control" file
+ * inside the ar archive, but tar.xz
+ * extraction code reaches end of xz data,
+ * reached this code and reads the beginning
+ * of data.tar.xz's ar header, which isn't xz data,
+ * and prints "corrupted data".
+ * The correct solution is to not read
+ * past nested archive (to simulate EOF).
+ * This is a workaround:
+ */
+ if (membuf[iobuf.in_pos] != 0xfd) {
+ /* It's definitely not a xz signature
+ * (which is 0xfd,"7zXZ",0x00).
+ */
+ goto end;
+ }
xz_dec_reset(state);
goto do_run;
}
break;
}
}
-
+ end:
xz_dec_end(state);
free(membuf);
#define STREAM_HEADER_SIZE 12
-#define HEADER_MAGIC "\3757zXZ"
+#define HEADER_MAGIC "\375""7zXZ"
#define HEADER_MAGIC_SIZE 6
#define FOOTER_MAGIC "YZ"
* was seen to cause largish delays when user tries to ^C a file copy.
* Let's use a saner size.
* Note: needs to be >= max(CONFIG_FEATURE_COPYBUF_KB),
- * or else "copy to eof" code will use neddlesly short reads.
+ * or else "copy to eof" code will use needlesly short reads.
*/
#define SENDFILE_BIGBUF (16*1024*1024)
ssize_t rd;
if (sendfile_sz) {
- rd = sendfile(dst_fd, src_fd, NULL,
- size > sendfile_sz ? sendfile_sz : size);
- if (rd >= 0)
- goto read_ok;
+ /* dst_fd == -1 is a fake, else... */
+ if (dst_fd >= 0) {
+ rd = sendfile(dst_fd, src_fd, NULL,
+ size > sendfile_sz ? sendfile_sz : size);
+ if (rd >= 0)
+ goto read_ok;
+ }
sendfile_sz = 0; /* do not try sendfile anymore */
}
#if CONFIG_FEATURE_COPYBUF_KB > 4