]>
Commit | Line | Data |
---|---|---|
fda2b22e AM |
1 | >From e54e1299404101a5a9d0cf5e45512b543967f958 Mon Sep 17 00:00:00 2001 |
2 | From: Mark Adler <madler@alumni.caltech.edu> | |
3 | Date: Sat, 5 Sep 2015 17:45:55 -0700 | |
4 | Subject: [PATCH] Avoid shifts of negative values inflateMark(). | |
5 | ||
6 | The C standard says that bit shifts of negative integers is | |
7 | undefined. This casts to unsigned values to assure a known | |
8 | result. | |
9 | --- | |
10 | inflate.c | 5 +++-- | |
11 | 1 file changed, 3 insertions(+), 2 deletions(-) | |
12 | ||
13 | diff --git a/zlib/inflate.c b/zlib/inflate.c | |
14 | index 2889e3a0..a7184167 100644 | |
15 | --- a/zlib/inflate.c | |
16 | +++ b/zlib/inflate.c | |
17 | @@ -1506,9 +1506,10 @@ z_streamp strm; | |
18 | { | |
19 | struct inflate_state FAR *state; | |
20 | ||
21 | - if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16; | |
22 | + if (strm == Z_NULL || strm->state == Z_NULL) | |
23 | + return (long)(((unsigned long)0 - 1) << 16); | |
24 | state = (struct inflate_state FAR *)strm->state; | |
25 | - return ((long)(state->back) << 16) + | |
26 | + return (long)(((unsigned long)((long)state->back)) << 16) + | |
27 | (state->mode == COPY ? state->length : | |
28 | (state->mode == MATCH ? state->was - state->length : 0)); | |
29 | } |