From owner-svn-src-all@FreeBSD.ORG Mon Nov 9 02:37:02 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9297F106568F; Mon, 9 Nov 2009 02:37:02 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 686A38FC1F; Mon, 9 Nov 2009 02:37:02 +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 nA92b2oI005473; Mon, 9 Nov 2009 02:37:02 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nA92b2m7005471; Mon, 9 Nov 2009 02:37:02 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200911090237.nA92b2m7005471@svn.freebsd.org> From: Xin LI Date: Mon, 9 Nov 2009 02:37:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199066 - head/usr.bin/gzip X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2009 02:37:02 -0000 Author: delphij Date: Mon Nov 9 02:37:02 2009 New Revision: 199066 URL: http://svn.freebsd.org/changeset/base/199066 Log: Apply a NetBSD fix (revision 1.12) to handle multi-session bzip2 files as created by pbzip2. Submitted by: mrg (NetBSD.org) MFC after: 1 week Modified: head/usr.bin/gzip/unbzip2.c Modified: head/usr.bin/gzip/unbzip2.c ============================================================================== --- head/usr.bin/gzip/unbzip2.c Mon Nov 9 00:16:50 2009 (r199065) +++ head/usr.bin/gzip/unbzip2.c Mon Nov 9 02:37:02 2009 (r199066) @@ -1,4 +1,4 @@ -/* $NetBSD: unbzip2.c,v 1.11 2008/04/28 20:24:13 martin Exp $ */ +/* $NetBSD: unbzip2.c,v 1.12 2009/10/11 05:17:20 mrg Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ unbzip2(int in, int out, char *pre, size if (bytes_in) *bytes_in = prelen; - while (ret >= BZ_OK && ret != BZ_STREAM_END) { + while (ret == BZ_OK) { if (bzs.avail_in == 0 && !end_of_file) { ssize_t n; @@ -88,7 +88,7 @@ unbzip2(int in, int out, char *pre, size case BZ_OK: if (ret == BZ_OK && end_of_file) maybe_err("read"); - if (!tflag) { + if (!tflag && bzs.avail_out != BUFLEN) { ssize_t n; n = write(out, outbuf, BUFLEN - bzs.avail_out); @@ -96,7 +96,13 @@ unbzip2(int in, int out, char *pre, size maybe_err("write"); bytes_out += n; } - break; + if (ret == BZ_STREAM_END && !end_of_file) { + if (BZ2_bzDecompressEnd(&bzs) != BZ_OK || + BZ2_bzDecompressInit(&bzs, 0, 0) != BZ_OK) + maybe_errx("bzip2 re-init"); + ret = BZ_OK; + } + break; case BZ_DATA_ERROR: maybe_warnx("bzip2 data integrity error"); @@ -109,7 +115,10 @@ unbzip2(int in, int out, char *pre, size case BZ_MEM_ERROR: maybe_warnx("bzip2 out of memory"); break; - + + default: + maybe_warnx("unknown bzip2 error: %d", ret); + break; } }