Deleted Added
full compact
unxz.c (319280) unxz.c (326559)
1/* $NetBSD: unxz.c,v 1.6 2016/01/29 15:19:01 christos Exp $ */
1/* $NetBSD: unxz.c,v 1.7 2017/08/04 07:27:08 mrg Exp $ */
2
3/*-
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
9 *

--- 14 unchanged lines hidden (view full) ---

24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31#include <sys/cdefs.h>
2
3/*-
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
9 *

--- 14 unchanged lines hidden (view full) ---

24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: stable/11/usr.bin/gzip/unxz.c 319280 2017-05-31 05:29:20Z delphij $");
32__FBSDID("$FreeBSD: stable/11/usr.bin/gzip/unxz.c 326559 2017-12-05 06:43:58Z delphij $");
33
34#include <stdarg.h>
35#include <errno.h>
36#include <stdio.h>
37#include <unistd.h>
38#include <lzma.h>
39
40static off_t

--- 10 unchanged lines hidden (view full) ---

51 if (bytes_in == NULL)
52 bytes_in = &bp;
53
54 strm.next_in = ibuf;
55 memcpy(ibuf, pre, prelen);
56 strm.avail_in = read(i, ibuf + prelen, sizeof(ibuf) - prelen);
57 if (strm.avail_in == (size_t)-1)
58 maybe_err("read failed");
33
34#include <stdarg.h>
35#include <errno.h>
36#include <stdio.h>
37#include <unistd.h>
38#include <lzma.h>
39
40static off_t

--- 10 unchanged lines hidden (view full) ---

51 if (bytes_in == NULL)
52 bytes_in = &bp;
53
54 strm.next_in = ibuf;
55 memcpy(ibuf, pre, prelen);
56 strm.avail_in = read(i, ibuf + prelen, sizeof(ibuf) - prelen);
57 if (strm.avail_in == (size_t)-1)
58 maybe_err("read failed");
59 infile_newdata(strm.avail_in);
59 strm.avail_in += prelen;
60 *bytes_in = strm.avail_in;
61
62 if ((ret = lzma_stream_decoder(&strm, UINT64_MAX, flags)) != LZMA_OK)
63 maybe_errx("Can't initialize decoder (%d)", ret);
64
65 strm.next_out = NULL;
66 strm.avail_out = 0;
67 if ((ret = lzma_code(&strm, LZMA_RUN)) != LZMA_OK)
68 maybe_errx("Can't read headers (%d)", ret);
69
70 bytes_out = 0;
71 strm.next_out = obuf;
72 strm.avail_out = sizeof(obuf);
73
74 for (;;) {
60 strm.avail_in += prelen;
61 *bytes_in = strm.avail_in;
62
63 if ((ret = lzma_stream_decoder(&strm, UINT64_MAX, flags)) != LZMA_OK)
64 maybe_errx("Can't initialize decoder (%d)", ret);
65
66 strm.next_out = NULL;
67 strm.avail_out = 0;
68 if ((ret = lzma_code(&strm, LZMA_RUN)) != LZMA_OK)
69 maybe_errx("Can't read headers (%d)", ret);
70
71 bytes_out = 0;
72 strm.next_out = obuf;
73 strm.avail_out = sizeof(obuf);
74
75 for (;;) {
76 check_siginfo();
75 if (strm.avail_in == 0) {
76 strm.next_in = ibuf;
77 strm.avail_in = read(i, ibuf, sizeof(ibuf));
78 switch (strm.avail_in) {
79 case (size_t)-1:
80 maybe_err("read failed");
81 /*NOTREACHED*/
82 case 0:
83 action = LZMA_FINISH;
84 break;
85 default:
77 if (strm.avail_in == 0) {
78 strm.next_in = ibuf;
79 strm.avail_in = read(i, ibuf, sizeof(ibuf));
80 switch (strm.avail_in) {
81 case (size_t)-1:
82 maybe_err("read failed");
83 /*NOTREACHED*/
84 case 0:
85 action = LZMA_FINISH;
86 break;
87 default:
88 infile_newdata(strm.avail_in);
86 *bytes_in += strm.avail_in;
87 break;
88 }
89 }
90
91 ret = lzma_code(&strm, action);
92
93 // Write and check write error before checking decoder error.

--- 60 unchanged lines hidden ---
89 *bytes_in += strm.avail_in;
90 break;
91 }
92 }
93
94 ret = lzma_code(&strm, action);
95
96 // Write and check write error before checking decoder error.

--- 60 unchanged lines hidden ---