From owner-svn-src-stable@FreeBSD.ORG Thu Sep 17 06:32:00 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E65B106566C; Thu, 17 Sep 2009 06:32:00 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 122408FC1D; Thu, 17 Sep 2009 06:32:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8H6Vxag047303; Thu, 17 Sep 2009 06:31:59 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8H6VxVg047300; Thu, 17 Sep 2009 06:31:59 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200909170631.n8H6VxVg047300@svn.freebsd.org> From: Tim Kientzle Date: Thu, 17 Sep 2009 06:31:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197266 - in stable/8/lib/libarchive: . test X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2009 06:32:00 -0000 Author: kientzle Date: Thu Sep 17 06:31:59 2009 New Revision: 197266 URL: http://svn.freebsd.org/changeset/base/197266 Log: MFC r196962: Fix /usr/bin/unzip: A bug deep in libarchive's read-ahead logic (incorrect handling of zero-length reads before the copy buffer is allocated) is masked by the iso9660 taster. Tar and cpio both enable that taster so were protected from the bug; unzip is susceptible. This both fixes the bug and updates the test harness to exercise this case. Submitted by: Ed Schouten diagnosed the bug and drafted a patch Approved by: re (kib) Modified: stable/8/lib/libarchive/ (props changed) stable/8/lib/libarchive/archive_read.c stable/8/lib/libarchive/test/test_compat_zip.c Modified: stable/8/lib/libarchive/archive_read.c ============================================================================== --- stable/8/lib/libarchive/archive_read.c Thu Sep 17 05:30:55 2009 (r197265) +++ stable/8/lib/libarchive/archive_read.c Thu Sep 17 06:31:59 2009 (r197266) @@ -928,9 +928,12 @@ __archive_read_filter_ahead(struct archi for (;;) { /* - * If we can satisfy from the copy buffer, we're done. + * If we can satisfy from the copy buffer (and the + * copy buffer isn't empty), we're done. In particular, + * note that min == 0 is a perfectly well-defined + * request. */ - if (filter->avail >= min) { + if (filter->avail >= min && filter->avail > 0) { if (avail != NULL) *avail = filter->avail; return (filter->next); Modified: stable/8/lib/libarchive/test/test_compat_zip.c ============================================================================== --- stable/8/lib/libarchive/test/test_compat_zip.c Thu Sep 17 05:30:55 2009 (r197265) +++ stable/8/lib/libarchive/test/test_compat_zip.c Thu Sep 17 06:31:59 2009 (r197266) @@ -36,7 +36,7 @@ test_compat_zip_1(void) assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); extract_reference_file(name); assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));