From 23ffb6a4a2a01fe41abe4e42d46fa16bdc2603fd Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 13 Feb 2008 17:52:42 +0000 Subject: tar: compat: handle tarballs with only one zero block at the end --- archival/libunarchive/get_header_tar.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c index 274bd46..7493d91 100644 --- a/archival/libunarchive/get_header_tar.c +++ b/archival/libunarchive/get_header_tar.c @@ -90,7 +90,15 @@ char get_header_tar(archive_handle_t *archive_handle) again_after_align: - xread(archive_handle->src_fd, &tar, 512); + i = full_read(archive_handle->src_fd, &tar, 512); + /* 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!), + * and tar will exit with error code 0! Mimic exit(0): */ + if (i == 0) + xfunc_error_retval = 0; + if (i != 512) + bb_error_msg_and_die("short read"); archive_handle->offset += 512; /* If there is no filename its an empty header */ -- cgit v1.1