commit 1ca406484d8e4f1be8c9bc5824d272fbc7c85ad2 Author: Jacob Welsh AuthorDate: Thu Apr 18 05:03:11 2024 +0000 Commit: Jacob Welsh CommitDate: Thu Apr 18 05:04:49 2024 +0000 busybox: tar as well as xread more generally didn't check for read errors, mistaking them for short reads. Test: "tar -tf ." Used to print: "tar: short read" Now prints: "tar: read error: Is a directory" diff --git a/base/busybox/archival/libarchive/get_header_tar.c b/base/busybox/archival/libarchive/get_header_tar.c index fb68673..8db1718 100644 --- a/base/busybox/archival/libarchive/get_header_tar.c +++ b/base/busybox/archival/libarchive/get_header_tar.c @@ -162,6 +162,9 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) /* to prevent misdetection of bz2 sig */ *(aliased_uint32_t*)&tar = 0; i = full_read(archive_handle->src_fd, &tar, 512); + if (i < 0) { + bb_perror_msg_and_die("read error"); + } /* If GNU tar sees EOF in above read, it says: * "tar: A lone zero block at N", where N = kilobyte * where EOF was met (not EOF block, actual EOF!), diff --git a/base/busybox/libbb/read_printf.c b/base/busybox/libbb/read_printf.c index b6a17cc..ed98041 100644 --- a/base/busybox/libbb/read_printf.c +++ b/base/busybox/libbb/read_printf.c @@ -214,6 +214,8 @@ void FAST_FUNC xread(int fd, void *buf, size_t count) { if (count) { ssize_t size = full_read(fd, buf, count); + if (size < 0) + bb_perror_msg_and_die("read error"); if ((size_t)size != count) bb_error_msg_and_die("short read"); }