From 085fce401bac81381be296026985e704e94a99e2 Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Thu, 27 Jun 2019 13:37:34 +0000 Subject: [PATCH] Update vendor/libarchive/dist to git d6d3799d6b309593f271c4c319dfba92efc95772 Relevant vendor changes: PR #1217: RAR5 reader - fix ARM filter going beyond window buffer boundary (OSS-Fuzz 15431) PR #1218: Fixes to sparse file handling --- .cirrus.yml | 10 ++++------ Makefile.am | 1 + .../{Dockerfile.fc29 => Dockerfile.fc30} | 2 +- ...e.fc29.distcheck => Dockerfile.fc30.distcheck} | 2 +- libarchive/archive_read.c | 3 ++- libarchive/archive_read_disk_posix.c | 2 ++ libarchive/archive_read_disk_windows.c | 2 ++ libarchive/archive_read_support_format_rar5.c | 4 ++-- libarchive/test/test_read_format_rar5.c | 15 +++++++++++++++ ...rmat_rar5_arm_filter_on_window_boundary.rar.uu | 9 +++++++++ 10 files changed, 39 insertions(+), 11 deletions(-) rename build/ci/cirrus_ci/{Dockerfile.fc29 => Dockerfile.fc30} (93%) rename build/ci/cirrus_ci/{Dockerfile.fc29.distcheck => Dockerfile.fc30.distcheck} (94%) create mode 100644 libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu diff --git a/.cirrus.yml b/.cirrus.yml index 21044fff79e0..33d6e473d9fa 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -35,8 +35,6 @@ MacOS_task: matrix: osx_instance: image: mojave-xcode-10.2 - osx_instance: - image: high-sierra-xcode-10.0 prepare_script: - ./build/ci/cirrus_ci/ci.sh prepare configure_script: @@ -50,9 +48,9 @@ MacOS_task: install_script: - ./build/ci/build.sh -a install -Fedora_29_task: +Fedora_30_task: container: - dockerfile: build/ci/cirrus_ci/Dockerfile.fc29 + dockerfile: build/ci/cirrus_ci/Dockerfile.fc30 matrix: env: BS: autotools @@ -68,9 +66,9 @@ Fedora_29_task: install_script: - ./build/ci/build.sh -a install -Fedora_29_distcheck_task: +Fedora_30_distcheck_task: container: - dockerfile: build/ci/cirrus_ci/Dockerfile.fc29.distcheck + dockerfile: build/ci/cirrus_ci/Dockerfile.fc30.distcheck env: BS: autotools configure_script: diff --git a/Makefile.am b/Makefile.am index 76703e4fe1b4..20eb5312e275 100644 --- a/Makefile.am +++ b/Makefile.am @@ -865,6 +865,7 @@ libarchive_test_EXTRA_DIST=\ libarchive/test/test_read_format_rar5_symlink.rar.uu \ libarchive/test/test_read_format_rar5_truncated_huff.rar.uu \ libarchive/test/test_read_format_rar5_win32.rar.uu \ + libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu \ libarchive/test/test_read_format_raw.bufr.uu \ libarchive/test/test_read_format_raw.data.gz.uu \ libarchive/test/test_read_format_raw.data.Z.uu \ diff --git a/build/ci/cirrus_ci/Dockerfile.fc29 b/build/ci/cirrus_ci/Dockerfile.fc30 similarity index 93% rename from build/ci/cirrus_ci/Dockerfile.fc29 rename to build/ci/cirrus_ci/Dockerfile.fc30 index d88176b174d8..2085d467b670 100644 --- a/build/ci/cirrus_ci/Dockerfile.fc29 +++ b/build/ci/cirrus_ci/Dockerfile.fc30 @@ -1,3 +1,3 @@ -FROM fedora:29 +FROM fedora:30 RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison sharutils pkgconf libacl-devel libasan librichacl-devel bzip2-devel libzip-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel diff --git a/build/ci/cirrus_ci/Dockerfile.fc29.distcheck b/build/ci/cirrus_ci/Dockerfile.fc30.distcheck similarity index 94% rename from build/ci/cirrus_ci/Dockerfile.fc29.distcheck rename to build/ci/cirrus_ci/Dockerfile.fc30.distcheck index 4470b5c39168..b59044be37a8 100644 --- a/build/ci/cirrus_ci/Dockerfile.fc29.distcheck +++ b/build/ci/cirrus_ci/Dockerfile.fc30.distcheck @@ -1,3 +1,3 @@ -FROM fedora:29 +FROM fedora:30 RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison sharutils pkgconf libacl-devel libasan librichacl-devel bzip2-devel libzip-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel groff ghostscript diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index de964f253284..5872601101ba 100644 --- a/libarchive/archive_read.c +++ b/libarchive/archive_read.c @@ -844,7 +844,8 @@ archive_read_data(struct archive *_a, void *buff, size_t s) dest = (char *)buff; while (s > 0) { - if (a->read_data_remaining == 0) { + if (a->read_data_offset == a->read_data_output_offset && + a->read_data_remaining == 0) { read_buf = a->read_data_block; a->read_data_is_posix_read = 1; a->read_data_requested = s; diff --git a/libarchive/archive_read_disk_posix.c b/libarchive/archive_read_disk_posix.c index c4df6c9436ba..87963c3c7c28 100644 --- a/libarchive/archive_read_disk_posix.c +++ b/libarchive/archive_read_disk_posix.c @@ -1143,6 +1143,8 @@ _archive_read_next_header2(struct archive *_a, struct archive_entry *entry) t->entry_fd = -1; } + archive_entry_clear(entry); + for (;;) { r = next_entry(a, t, entry); if (t->entry_fd >= 0) { diff --git a/libarchive/archive_read_disk_windows.c b/libarchive/archive_read_disk_windows.c index 4a5421f8f30e..fdd376f9b945 100644 --- a/libarchive/archive_read_disk_windows.c +++ b/libarchive/archive_read_disk_windows.c @@ -1126,6 +1126,8 @@ _archive_read_next_header2(struct archive *_a, struct archive_entry *entry) t->entry_fh = INVALID_HANDLE_VALUE; } + archive_entry_clear(entry); + while ((r = next_entry(a, t, entry)) == ARCHIVE_RETRY) archive_entry_clear(entry); diff --git a/libarchive/archive_read_support_format_rar5.c b/libarchive/archive_read_support_format_rar5.c index 95579e15cf05..e58cbbf6d829 100644 --- a/libarchive/archive_read_support_format_rar5.c +++ b/libarchive/archive_read_support_format_rar5.c @@ -623,9 +623,9 @@ static int run_arm_filter(struct rar5* rar, struct filter_info* flt) { for(i = 0; i < flt->block_length - 3; i += 4) { uint8_t* b = &rar->cstate.window_buf[ (rar->cstate.solid_offset + - flt->block_start + i) & rar->cstate.window_mask]; + flt->block_start + i + 3) & rar->cstate.window_mask]; - if(b[3] == 0xEB) { + if(*b == 0xEB) { /* 0xEB = ARM's BL (branch + link) instruction. */ offset = read_filter_data(rar, (rar->cstate.solid_offset + flt->block_start + i) & diff --git a/libarchive/test/test_read_format_rar5.c b/libarchive/test/test_read_format_rar5.c index 2a55e2015510..b4ef29e464bf 100644 --- a/libarchive/test/test_read_format_rar5.c +++ b/libarchive/test/test_read_format_rar5.c @@ -1215,3 +1215,18 @@ DEFINE_TEST(test_read_format_rar5_different_window_size) EPILOGUE(); } + +DEFINE_TEST(test_read_format_rar5_arm_filter_on_window_boundary) +{ + char buf[4096]; + PROLOGUE("test_read_format_rar5_arm_filter_on_window_boundary.rar"); + + /* Return codes of those calls are ignored, because this sample file + * is invalid. However, the unpacker shouldn't produce any SIGSEGV + * errors during processing. */ + + (void) archive_read_next_header(a, &ae); + while(0 != archive_read_data(a, buf, sizeof(buf))) {} + + EPILOGUE(); +} diff --git a/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu b/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu new file mode 100644 index 000000000000..b2b9fdb6087a --- /dev/null +++ b/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu @@ -0,0 +1,9 @@ +begin 600 test_read_format_rar5_arm_filter_on_window_boundary.rar +M4F%R(1H'`0"-[P+2``(''(`'`/[_(`#_!``"(0$``/X(TB`!'O___P@``/W_ +M_Q``_]U84%"0_P1LAFVQ9,S,M[$`20"#__\`_P#_`/G___!DSR0V2+$`20`Z +M@R[_______\I:!<**-@P70D`KB1!