mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-03 12:35:02 +00:00
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
This commit is contained in:
parent
4d3a629c65
commit
0c10c611ff
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=199066
@ -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_t prelen, off_t *bytes_in)
|
||||
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_t prelen, off_t *bytes_in)
|
||||
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_t prelen, off_t *bytes_in)
|
||||
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_t prelen, off_t *bytes_in)
|
||||
case BZ_MEM_ERROR:
|
||||
maybe_warnx("bzip2 out of memory");
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
maybe_warnx("unknown bzip2 error: %d", ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user