2 63581804 2018-07-09 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
4 63581804 2018-07-09 stsp * Permission to use, copy, modify, and distribute this software for any
5 63581804 2018-07-09 stsp * purpose with or without fee is hereby granted, provided that the above
6 63581804 2018-07-09 stsp * copyright notice and this permission notice appear in all copies.
8 63581804 2018-07-09 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 63581804 2018-07-09 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 63581804 2018-07-09 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 63581804 2018-07-09 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 63581804 2018-07-09 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 63581804 2018-07-09 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 63581804 2018-07-09 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 63581804 2018-07-09 stsp #include <sys/queue.h>
19 5211b8c8 2019-03-19 stsp #include <errno.h>
20 63581804 2018-07-09 stsp #include <stdio.h>
21 63581804 2018-07-09 stsp #include <stdlib.h>
22 63581804 2018-07-09 stsp #include <string.h>
23 63581804 2018-07-09 stsp #include <sha1.h>
24 63581804 2018-07-09 stsp #include <zlib.h>
25 63581804 2018-07-09 stsp #include <time.h>
27 63581804 2018-07-09 stsp #include "got_error.h"
28 63581804 2018-07-09 stsp #include "got_object.h"
29 324d37e7 2019-05-11 stsp #include "got_path.h"
31 63581804 2018-07-09 stsp #include "got_lib_inflate.h"
34 63581804 2018-07-09 stsp #define MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
37 63581804 2018-07-09 stsp const struct got_error *
38 23bc48a9 2019-03-19 stsp got_inflate_init(struct got_inflate_buf *zb, uint8_t *outbuf, size_t bufsize)
40 63581804 2018-07-09 stsp const struct got_error *err = NULL;
43 63581804 2018-07-09 stsp memset(&zb->z, 0, sizeof(zb->z));
45 63581804 2018-07-09 stsp zb->z.zalloc = Z_NULL;
46 63581804 2018-07-09 stsp zb->z.zfree = Z_NULL;
47 5211b8c8 2019-03-19 stsp zerr = inflateInit(&zb->z);
48 5211b8c8 2019-03-19 stsp if (zerr != Z_OK) {
49 5211b8c8 2019-03-19 stsp if (zerr == Z_ERRNO)
50 638f9024 2019-05-13 stsp return got_error_from_errno("inflateInit");
51 5211b8c8 2019-03-19 stsp if (zerr == Z_MEM_ERROR) {
52 5211b8c8 2019-03-19 stsp errno = ENOMEM;
53 638f9024 2019-05-13 stsp return got_error_from_errno("inflateInit");
55 5211b8c8 2019-03-19 stsp return got_error(GOT_ERR_DECOMPRESSION);
58 63581804 2018-07-09 stsp zb->inlen = zb->outlen = bufsize;
60 63581804 2018-07-09 stsp zb->inbuf = calloc(1, zb->inlen);
61 63581804 2018-07-09 stsp if (zb->inbuf == NULL) {
62 638f9024 2019-05-13 stsp err = got_error_from_errno("calloc");
66 63581804 2018-07-09 stsp zb->flags = 0;
67 63581804 2018-07-09 stsp if (outbuf == NULL) {
68 63581804 2018-07-09 stsp zb->outbuf = calloc(1, zb->outlen);
69 63581804 2018-07-09 stsp if (zb->outbuf == NULL) {
70 638f9024 2019-05-13 stsp err = got_error_from_errno("calloc");
73 23bc48a9 2019-03-19 stsp zb->flags |= GOT_INFLATE_F_OWN_OUTBUF;
75 63581804 2018-07-09 stsp zb->outbuf = outbuf;
79 63581804 2018-07-09 stsp got_inflate_end(zb);
83 63581804 2018-07-09 stsp const struct got_error *
84 23bc48a9 2019-03-19 stsp got_inflate_read(struct got_inflate_buf *zb, FILE *f, size_t *outlenp)
86 63581804 2018-07-09 stsp size_t last_total_out = zb->z.total_out;
87 63581804 2018-07-09 stsp z_stream *z = &zb->z;
88 63581804 2018-07-09 stsp int ret = Z_ERRNO;
90 63581804 2018-07-09 stsp z->next_out = zb->outbuf;
91 63581804 2018-07-09 stsp z->avail_out = zb->outlen;
93 63581804 2018-07-09 stsp *outlenp = 0;
95 63581804 2018-07-09 stsp if (z->avail_in == 0) {
96 63581804 2018-07-09 stsp size_t n = fread(zb->inbuf, 1, zb->inlen, f);
97 63581804 2018-07-09 stsp if (n == 0) {
98 63581804 2018-07-09 stsp if (ferror(f))
99 63581804 2018-07-09 stsp return got_ferror(f, GOT_ERR_IO);
101 63581804 2018-07-09 stsp ret = Z_STREAM_END;
104 63581804 2018-07-09 stsp z->next_in = zb->inbuf;
105 63581804 2018-07-09 stsp z->avail_in = n;
107 63581804 2018-07-09 stsp ret = inflate(z, Z_SYNC_FLUSH);
108 63581804 2018-07-09 stsp } while (ret == Z_OK && z->avail_out > 0);
110 63581804 2018-07-09 stsp if (ret == Z_OK) {
111 23bc48a9 2019-03-19 stsp zb->flags |= GOT_INFLATE_F_HAVE_MORE;
113 63581804 2018-07-09 stsp if (ret != Z_STREAM_END)
114 63581804 2018-07-09 stsp return got_error(GOT_ERR_DECOMPRESSION);
115 23bc48a9 2019-03-19 stsp zb->flags &= ~GOT_INFLATE_F_HAVE_MORE;
118 63581804 2018-07-09 stsp *outlenp = z->total_out - last_total_out;
119 63581804 2018-07-09 stsp return NULL;
122 63581804 2018-07-09 stsp const struct got_error *
123 23bc48a9 2019-03-19 stsp got_inflate_read_fd(struct got_inflate_buf *zb, int fd, size_t *outlenp)
125 63581804 2018-07-09 stsp size_t last_total_out = zb->z.total_out;
126 63581804 2018-07-09 stsp z_stream *z = &zb->z;
127 63581804 2018-07-09 stsp int ret = Z_ERRNO;
129 63581804 2018-07-09 stsp z->next_out = zb->outbuf;
130 63581804 2018-07-09 stsp z->avail_out = zb->outlen;
132 63581804 2018-07-09 stsp *outlenp = 0;
134 63581804 2018-07-09 stsp if (z->avail_in == 0) {
135 63581804 2018-07-09 stsp ssize_t n = read(fd, zb->inbuf, zb->inlen);
137 638f9024 2019-05-13 stsp return got_error_from_errno("read");
138 63581804 2018-07-09 stsp else if (n == 0) {
140 63581804 2018-07-09 stsp ret = Z_STREAM_END;
143 63581804 2018-07-09 stsp z->next_in = zb->inbuf;
144 63581804 2018-07-09 stsp z->avail_in = n;
146 63581804 2018-07-09 stsp ret = inflate(z, Z_SYNC_FLUSH);
147 63581804 2018-07-09 stsp } while (ret == Z_OK && z->avail_out > 0);
149 63581804 2018-07-09 stsp if (ret == Z_OK) {
150 23bc48a9 2019-03-19 stsp zb->flags |= GOT_INFLATE_F_HAVE_MORE;
152 63581804 2018-07-09 stsp if (ret != Z_STREAM_END)
153 63581804 2018-07-09 stsp return got_error(GOT_ERR_DECOMPRESSION);
154 23bc48a9 2019-03-19 stsp zb->flags &= ~GOT_INFLATE_F_HAVE_MORE;
157 63581804 2018-07-09 stsp *outlenp = z->total_out - last_total_out;
158 63581804 2018-07-09 stsp return NULL;
161 63581804 2018-07-09 stsp const struct got_error *
162 23bc48a9 2019-03-19 stsp got_inflate_read_mmap(struct got_inflate_buf *zb, uint8_t *map, size_t offset,
163 63581804 2018-07-09 stsp size_t len, size_t *outlenp, size_t *consumed)
165 63581804 2018-07-09 stsp size_t last_total_out = zb->z.total_out;
166 63581804 2018-07-09 stsp z_stream *z = &zb->z;
167 63581804 2018-07-09 stsp int ret = Z_ERRNO;
169 63581804 2018-07-09 stsp z->next_out = zb->outbuf;
170 63581804 2018-07-09 stsp z->avail_out = zb->outlen;
172 63581804 2018-07-09 stsp *outlenp = 0;
173 63581804 2018-07-09 stsp *consumed = 0;
176 37bd7602 2018-07-23 stsp size_t last_total_in = zb->z.total_in;
177 63581804 2018-07-09 stsp if (z->avail_in == 0) {
178 63581804 2018-07-09 stsp if (len == 0) {
180 63581804 2018-07-09 stsp ret = Z_STREAM_END;
183 37bd7602 2018-07-23 stsp z->next_in = map + offset + *consumed;
184 63581804 2018-07-09 stsp z->avail_in = MIN(zb->inlen, len);
185 63581804 2018-07-09 stsp len -= z->avail_in;
187 63581804 2018-07-09 stsp ret = inflate(z, Z_SYNC_FLUSH);
188 37bd7602 2018-07-23 stsp *consumed += z->total_in - last_total_in;
189 63581804 2018-07-09 stsp } while (ret == Z_OK && z->avail_out > 0);
191 63581804 2018-07-09 stsp if (ret == Z_OK) {
192 23bc48a9 2019-03-19 stsp zb->flags |= GOT_INFLATE_F_HAVE_MORE;
194 63581804 2018-07-09 stsp if (ret != Z_STREAM_END)
195 63581804 2018-07-09 stsp return got_error(GOT_ERR_DECOMPRESSION);
196 23bc48a9 2019-03-19 stsp zb->flags &= ~GOT_INFLATE_F_HAVE_MORE;
199 63581804 2018-07-09 stsp *outlenp = z->total_out - last_total_out;
200 63581804 2018-07-09 stsp return NULL;
204 23bc48a9 2019-03-19 stsp got_inflate_end(struct got_inflate_buf *zb)
206 63581804 2018-07-09 stsp free(zb->inbuf);
207 23bc48a9 2019-03-19 stsp if (zb->flags & GOT_INFLATE_F_OWN_OUTBUF)
208 63581804 2018-07-09 stsp free(zb->outbuf);
209 63581804 2018-07-09 stsp inflateEnd(&zb->z);
212 63581804 2018-07-09 stsp const struct got_error *
213 63581804 2018-07-09 stsp got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, FILE *f)
215 63581804 2018-07-09 stsp const struct got_error *err;
216 63581804 2018-07-09 stsp size_t avail;
217 23bc48a9 2019-03-19 stsp struct got_inflate_buf zb;
218 63581804 2018-07-09 stsp void *newbuf;
219 17d745b8 2018-07-23 stsp int nbuf = 1;
221 6dc3b75a 2019-05-22 stsp *outbuf = malloc(GOT_INFLATE_BUFSIZE);
222 63581804 2018-07-09 stsp if (*outbuf == NULL)
223 6331840f 2019-05-22 stsp return got_error_from_errno("malloc");
224 23bc48a9 2019-03-19 stsp err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
226 63581804 2018-07-09 stsp return err;
228 63581804 2018-07-09 stsp *outlen = 0;
231 63581804 2018-07-09 stsp err = got_inflate_read(&zb, f, &avail);
234 63581804 2018-07-09 stsp *outlen += avail;
235 23bc48a9 2019-03-19 stsp if (zb.flags & GOT_INFLATE_F_HAVE_MORE) {
236 6dc3b75a 2019-05-22 stsp newbuf = reallocarray(*outbuf, ++nbuf,
237 23bc48a9 2019-03-19 stsp GOT_INFLATE_BUFSIZE);
238 63581804 2018-07-09 stsp if (newbuf == NULL) {
239 6dc3b75a 2019-05-22 stsp err = got_error_from_errno("reallocarray");
240 63581804 2018-07-09 stsp free(*outbuf);
241 63581804 2018-07-09 stsp *outbuf = NULL;
242 63581804 2018-07-09 stsp *outlen = 0;
245 63581804 2018-07-09 stsp *outbuf = newbuf;
246 63581804 2018-07-09 stsp zb.outbuf = newbuf + *outlen;
247 23bc48a9 2019-03-19 stsp zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen;
249 23bc48a9 2019-03-19 stsp } while (zb.flags & GOT_INFLATE_F_HAVE_MORE);
252 63581804 2018-07-09 stsp got_inflate_end(&zb);
253 63581804 2018-07-09 stsp return err;
256 63581804 2018-07-09 stsp const struct got_error *
257 63581804 2018-07-09 stsp got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen, int infd)
259 63581804 2018-07-09 stsp const struct got_error *err;
260 63581804 2018-07-09 stsp size_t avail;
261 23bc48a9 2019-03-19 stsp struct got_inflate_buf zb;
262 63581804 2018-07-09 stsp void *newbuf;
263 17d745b8 2018-07-23 stsp int nbuf = 1;
265 f2c5fe0e 2019-05-22 stsp *outbuf = malloc(GOT_INFLATE_BUFSIZE);
266 63581804 2018-07-09 stsp if (*outbuf == NULL)
267 6331840f 2019-05-22 stsp return got_error_from_errno("malloc");
268 23bc48a9 2019-03-19 stsp err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
272 63581804 2018-07-09 stsp *outlen = 0;
275 63581804 2018-07-09 stsp err = got_inflate_read_fd(&zb, infd, &avail);
278 63581804 2018-07-09 stsp *outlen += avail;
279 23bc48a9 2019-03-19 stsp if (zb.flags & GOT_INFLATE_F_HAVE_MORE) {
280 f2c5fe0e 2019-05-22 stsp newbuf = reallocarray(*outbuf, ++nbuf,
281 23bc48a9 2019-03-19 stsp GOT_INFLATE_BUFSIZE);
282 63581804 2018-07-09 stsp if (newbuf == NULL) {
283 f2c5fe0e 2019-05-22 stsp err = got_error_from_errno("reallocarray");
284 63581804 2018-07-09 stsp free(*outbuf);
285 63581804 2018-07-09 stsp *outbuf = NULL;
286 63581804 2018-07-09 stsp *outlen = 0;
289 63581804 2018-07-09 stsp *outbuf = newbuf;
290 63581804 2018-07-09 stsp zb.outbuf = newbuf + *outlen;
291 23bc48a9 2019-03-19 stsp zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen;
293 23bc48a9 2019-03-19 stsp } while (zb.flags & GOT_INFLATE_F_HAVE_MORE);
296 63581804 2018-07-09 stsp got_inflate_end(&zb);
297 63581804 2018-07-09 stsp return err;
300 63581804 2018-07-09 stsp const struct got_error *
301 63581804 2018-07-09 stsp got_inflate_to_mem_mmap(uint8_t **outbuf, size_t *outlen, uint8_t *map,
302 63581804 2018-07-09 stsp size_t offset, size_t len)
304 63581804 2018-07-09 stsp const struct got_error *err;
305 37bd7602 2018-07-23 stsp size_t avail, consumed;
306 23bc48a9 2019-03-19 stsp struct got_inflate_buf zb;
307 63581804 2018-07-09 stsp void *newbuf;
308 37bd7602 2018-07-23 stsp int nbuf = 1;
310 b3a605ce 2019-05-22 stsp *outbuf = malloc(GOT_INFLATE_BUFSIZE);
311 63581804 2018-07-09 stsp if (*outbuf == NULL)
312 6331840f 2019-05-22 stsp return got_error_from_errno("malloc");
313 23bc48a9 2019-03-19 stsp err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
315 60507209 2018-07-13 stsp free(*outbuf);
316 60507209 2018-07-13 stsp *outbuf = NULL;
317 63581804 2018-07-09 stsp return err;
320 63581804 2018-07-09 stsp *outlen = 0;
323 63581804 2018-07-09 stsp err = got_inflate_read_mmap(&zb, map, offset, len, &avail,
324 63581804 2018-07-09 stsp &consumed);
327 63581804 2018-07-09 stsp offset += consumed;
328 63581804 2018-07-09 stsp len -= consumed;
329 63581804 2018-07-09 stsp *outlen += avail;
330 63581804 2018-07-09 stsp if (len == 0)
332 23bc48a9 2019-03-19 stsp if (zb.flags & GOT_INFLATE_F_HAVE_MORE) {
333 b3a605ce 2019-05-22 stsp newbuf = reallocarray(*outbuf, ++nbuf,
334 23bc48a9 2019-03-19 stsp GOT_INFLATE_BUFSIZE);
335 63581804 2018-07-09 stsp if (newbuf == NULL) {
336 b3a605ce 2019-05-22 stsp err = got_error_from_errno("reallocarray");
337 63581804 2018-07-09 stsp free(*outbuf);
338 63581804 2018-07-09 stsp *outbuf = NULL;
339 63581804 2018-07-09 stsp *outlen = 0;
342 63581804 2018-07-09 stsp *outbuf = newbuf;
343 63581804 2018-07-09 stsp zb.outbuf = newbuf + *outlen;
344 23bc48a9 2019-03-19 stsp zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen;
346 23bc48a9 2019-03-19 stsp } while (zb.flags & GOT_INFLATE_F_HAVE_MORE);
348 63581804 2018-07-09 stsp got_inflate_end(&zb);
349 63581804 2018-07-09 stsp return err;
352 63581804 2018-07-09 stsp const struct got_error *
353 63581804 2018-07-09 stsp got_inflate_to_fd(size_t *outlen, FILE *infile, int outfd)
355 63581804 2018-07-09 stsp const struct got_error *err = NULL;
356 63581804 2018-07-09 stsp size_t avail;
357 23bc48a9 2019-03-19 stsp struct got_inflate_buf zb;
359 23bc48a9 2019-03-19 stsp err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE);
363 63581804 2018-07-09 stsp *outlen = 0;
366 63581804 2018-07-09 stsp err = got_inflate_read(&zb, infile, &avail);
369 63581804 2018-07-09 stsp if (avail > 0) {
371 63581804 2018-07-09 stsp n = write(outfd, zb.outbuf, avail);
372 63581804 2018-07-09 stsp if (n != avail) {
373 638f9024 2019-05-13 stsp err = got_error_from_errno("write");
376 63581804 2018-07-09 stsp *outlen += avail;
378 23bc48a9 2019-03-19 stsp } while (zb.flags & GOT_INFLATE_F_HAVE_MORE);
381 63581804 2018-07-09 stsp if (err == NULL) {
382 63581804 2018-07-09 stsp if (lseek(outfd, SEEK_SET, 0) == -1)
383 638f9024 2019-05-13 stsp err = got_error_from_errno("lseek");
385 63581804 2018-07-09 stsp got_inflate_end(&zb);
386 63581804 2018-07-09 stsp return err;
389 63581804 2018-07-09 stsp const struct got_error *
390 63581804 2018-07-09 stsp got_inflate_to_file(size_t *outlen, FILE *infile, FILE *outfile)
392 63581804 2018-07-09 stsp const struct got_error *err;
393 63581804 2018-07-09 stsp size_t avail;
394 23bc48a9 2019-03-19 stsp struct got_inflate_buf zb;
396 23bc48a9 2019-03-19 stsp err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE);
400 63581804 2018-07-09 stsp *outlen = 0;
403 63581804 2018-07-09 stsp err = got_inflate_read(&zb, infile, &avail);
406 63581804 2018-07-09 stsp if (avail > 0) {
408 63581804 2018-07-09 stsp n = fwrite(zb.outbuf, avail, 1, outfile);
409 63581804 2018-07-09 stsp if (n != 1) {
410 63581804 2018-07-09 stsp err = got_ferror(outfile, GOT_ERR_IO);
413 63581804 2018-07-09 stsp *outlen += avail;
415 23bc48a9 2019-03-19 stsp } while (zb.flags & GOT_INFLATE_F_HAVE_MORE);
418 63581804 2018-07-09 stsp if (err == NULL)
419 63581804 2018-07-09 stsp rewind(outfile);
420 63581804 2018-07-09 stsp got_inflate_end(&zb);
421 63581804 2018-07-09 stsp return err;
424 63581804 2018-07-09 stsp const struct got_error *
425 63581804 2018-07-09 stsp got_inflate_to_file_fd(size_t *outlen, int infd, FILE *outfile)
427 63581804 2018-07-09 stsp const struct got_error *err;
428 63581804 2018-07-09 stsp size_t avail;
429 23bc48a9 2019-03-19 stsp struct got_inflate_buf zb;
431 23bc48a9 2019-03-19 stsp err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE);
435 63581804 2018-07-09 stsp *outlen = 0;
438 63581804 2018-07-09 stsp err = got_inflate_read_fd(&zb, infd, &avail);
441 63581804 2018-07-09 stsp if (avail > 0) {
443 63581804 2018-07-09 stsp n = fwrite(zb.outbuf, avail, 1, outfile);
444 63581804 2018-07-09 stsp if (n != 1) {
445 63581804 2018-07-09 stsp err = got_ferror(outfile, GOT_ERR_IO);
448 63581804 2018-07-09 stsp *outlen += avail;
450 23bc48a9 2019-03-19 stsp } while (zb.flags & GOT_INFLATE_F_HAVE_MORE);
453 63581804 2018-07-09 stsp if (err == NULL)
454 63581804 2018-07-09 stsp rewind(outfile);
455 63581804 2018-07-09 stsp got_inflate_end(&zb);
456 63581804 2018-07-09 stsp return err;
459 63581804 2018-07-09 stsp const struct got_error *
460 63581804 2018-07-09 stsp got_inflate_to_file_mmap(size_t *outlen, uint8_t *map, size_t offset,
461 63581804 2018-07-09 stsp size_t len, FILE *outfile)
463 63581804 2018-07-09 stsp const struct got_error *err;
464 63581804 2018-07-09 stsp size_t avail;
465 23bc48a9 2019-03-19 stsp struct got_inflate_buf zb;
466 63581804 2018-07-09 stsp size_t consumed;
468 23bc48a9 2019-03-19 stsp err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE);
472 63581804 2018-07-09 stsp *outlen = 0;
475 63581804 2018-07-09 stsp err = got_inflate_read_mmap(&zb, map, offset, len, &avail,
476 63581804 2018-07-09 stsp &consumed);
479 63581804 2018-07-09 stsp offset += consumed;
480 63581804 2018-07-09 stsp len -= consumed;
481 63581804 2018-07-09 stsp if (avail > 0) {
483 63581804 2018-07-09 stsp n = fwrite(zb.outbuf, avail, 1, outfile);
484 63581804 2018-07-09 stsp if (n != 1) {
485 63581804 2018-07-09 stsp err = got_ferror(outfile, GOT_ERR_IO);
488 63581804 2018-07-09 stsp *outlen += avail;
490 23bc48a9 2019-03-19 stsp } while (zb.flags & GOT_INFLATE_F_HAVE_MORE);
493 63581804 2018-07-09 stsp if (err == NULL)
494 63581804 2018-07-09 stsp rewind(outfile);
495 63581804 2018-07-09 stsp got_inflate_end(&zb);
496 63581804 2018-07-09 stsp return err;