Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jul 2019 00:21:15 +0000 (UTC)
From:      Martin Matuska <mm@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r349899 - in stable/12: contrib/libarchive/libarchive contrib/libarchive/libarchive/test lib/libarchive/tests
Message-ID:  <201907110021.x6B0LFsM021994@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mm
Date: Thu Jul 11 00:21:15 2019
New Revision: 349899
URL: https://svnweb.freebsd.org/changeset/base/349899

Log:
  MFC r349527,349538:
  Sync libarchive with vendor.
  
  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

Added:
  stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu
     - copied unchanged from r349527, head/contrib/libarchive/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu
Modified:
  stable/12/contrib/libarchive/libarchive/archive_read.c
  stable/12/contrib/libarchive/libarchive/archive_read_disk_posix.c
  stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar5.c
  stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5.c
  stable/12/lib/libarchive/tests/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/libarchive/libarchive/archive_read.c
==============================================================================
--- stable/12/contrib/libarchive/libarchive/archive_read.c	Thu Jul 11 00:08:46 2019	(r349898)
+++ stable/12/contrib/libarchive/libarchive/archive_read.c	Thu Jul 11 00:21:15 2019	(r349899)
@@ -844,7 +844,8 @@ archive_read_data(struct archive *_a, void *buff, size
 	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;

Modified: stable/12/contrib/libarchive/libarchive/archive_read_disk_posix.c
==============================================================================
--- stable/12/contrib/libarchive/libarchive/archive_read_disk_posix.c	Thu Jul 11 00:08:46 2019	(r349898)
+++ stable/12/contrib/libarchive/libarchive/archive_read_disk_posix.c	Thu Jul 11 00:21:15 2019	(r349899)
@@ -1143,6 +1143,8 @@ _archive_read_next_header2(struct archive *_a, struct 
 		t->entry_fd = -1;
 	}
 
+	archive_entry_clear(entry);
+
 	for (;;) {
 		r = next_entry(a, t, entry);
 		if (t->entry_fd >= 0) {

Modified: stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar5.c
==============================================================================
--- stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar5.c	Thu Jul 11 00:08:46 2019	(r349898)
+++ stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar5.c	Thu Jul 11 00:21:15 2019	(r349899)
@@ -623,9 +623,9 @@ static int run_arm_filter(struct rar5* rar, struct fil
 	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) &

Modified: stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5.c
==============================================================================
--- stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5.c	Thu Jul 11 00:08:46 2019	(r349898)
+++ stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5.c	Thu Jul 11 00:21:15 2019	(r349899)
@@ -1215,3 +1215,18 @@ DEFINE_TEST(test_read_format_rar5_different_window_siz
 
 	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();
+}

Copied: stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu (from r349527, head/contrib/libarchive/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu	Thu Jul 11 00:21:15 2019	(r349899, copy of r349527, head/contrib/libarchive/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!<YOZFQ/___^<`^5L*0```/________\_
+M`0#__RE@%PHHV#!="0"N)$%S"```_?]84/7___]0D/\$;(9ML63,S/\R'Q\?
+M'Q\?'Q\?'Q\?'Q\?'[$`20"#__\`_P#_`/G___!DSR0V2+$`20`Z@R[_____
+0_Q\?'Q\?'Q\?'Q]5"E`*4```
+`
+end

Modified: stable/12/lib/libarchive/tests/Makefile
==============================================================================
--- stable/12/lib/libarchive/tests/Makefile	Thu Jul 11 00:08:46 2019	(r349898)
+++ stable/12/lib/libarchive/tests/Makefile	Thu Jul 11 00:21:15 2019	(r349899)
@@ -512,6 +512,7 @@ ${PACKAGE}FILES+=	test_read_format_rar_subblock.rar.uu
 ${PACKAGE}FILES+=	test_read_format_rar_unicode.rar.uu
 ${PACKAGE}FILES+=	test_read_format_rar_windows.rar.uu
 ${PACKAGE}FILES+=	test_read_format_rar5_arm.rar.uu
+${PACKAGE}FILES+=	test_read_format_rar5_arm_filter_on_window_boundary.rar.uu
 ${PACKAGE}FILES+=	test_read_format_rar5_blake2.rar.uu
 ${PACKAGE}FILES+=	test_read_format_rar5_compressed.rar.uu
 ${PACKAGE}FILES+=	test_read_format_rar5_different_window_size.rar.uu



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907110021.x6B0LFsM021994>