Restore a local change (in rev1.4) that was lost on zlib 1.12.10 merge.

The rev 1.4 changelog:
> Disable a sanity check output buffer != NULL in _STANDALONE case.
> Some kernels are loaded at address 0x0 by bootloaders and
> output buffer address could be zero in such case.
>
> Fixes "read text" errors on loading install floppy of NetBSD/news68k 4.0,
> reported by KIYOHARA Takashi on port-news68k.

This problem may also affect other m68k ports which use a gzipped install
kernel and kernel text address located at PA 0x0.

Should be pulled up to netbsd-8.
This commit is contained in:
tsutsui 2017-11-12 07:55:05 +00:00
parent c1cc3cb6de
commit 6dd94d2a84

View File

@ -1,4 +1,4 @@
/* $NetBSD: inflate.c,v 1.5 2017/01/10 01:27:41 christos Exp $ */
/* $NetBSD: inflate.c,v 1.6 2017/11/12 07:55:05 tsutsui Exp $ */
/* inflate.c -- zlib decompression
* Copyright (C) 1995-2016 Mark Adler
@ -644,9 +644,16 @@ int flush;
static const unsigned short order[19] = /* permutation of code lengths */
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
#if defined(__NetBSD__) && defined(_STANDALONE)
/* Some kernels are loaded at address 0x0 so strm->next_out could be NULL */
if (inflateStateCheck(strm) ||
(strm->next_in == Z_NULL && strm->avail_in != 0))
return Z_STREAM_ERROR;
#else
if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
(strm->next_in == Z_NULL && strm->avail_in != 0))
return Z_STREAM_ERROR;
#endif
state = (struct inflate_state FAR *)strm->state;
if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */