gunzip: inflate_codes(): add fix from upstream gzip to prevent false CRC error
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
80f4275629
commit
0866b36900
@ -575,13 +575,16 @@ static NOINLINE int inflate_codes(STATE_PARAM_ONLY)
|
|||||||
do {
|
do {
|
||||||
/* Was: nn -= (e = (e = GUNZIP_WSIZE - ((dd &= GUNZIP_WSIZE - 1) > w ? dd : w)) > nn ? nn : e); */
|
/* Was: nn -= (e = (e = GUNZIP_WSIZE - ((dd &= GUNZIP_WSIZE - 1) > w ? dd : w)) > nn ? nn : e); */
|
||||||
/* Who wrote THAT?? rewritten as: */
|
/* Who wrote THAT?? rewritten as: */
|
||||||
|
unsigned delta;
|
||||||
|
|
||||||
dd &= GUNZIP_WSIZE - 1;
|
dd &= GUNZIP_WSIZE - 1;
|
||||||
e = GUNZIP_WSIZE - (dd > w ? dd : w);
|
e = GUNZIP_WSIZE - (dd > w ? dd : w);
|
||||||
|
delta = w > dd ? w - dd : dd - w;
|
||||||
if (e > nn) e = nn;
|
if (e > nn) e = nn;
|
||||||
nn -= e;
|
nn -= e;
|
||||||
|
|
||||||
/* copy to new buffer to prevent possible overwrite */
|
/* copy to new buffer to prevent possible overwrite */
|
||||||
if (w - dd >= e) { /* (this test assumes unsigned comparison) */
|
if (delta >= e) {
|
||||||
memcpy(gunzip_window + w, gunzip_window + dd, e);
|
memcpy(gunzip_window + w, gunzip_window + dd, e);
|
||||||
w += e;
|
w += e;
|
||||||
dd += e;
|
dd += e;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user