diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2015-09-05 17:45:55 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2015-09-05 17:45:55 -0700 |
commit | e54e1299404101a5a9d0cf5e45512b543967f958 (patch) | |
tree | b7e6413290d34be2215d8e447afae33a4baf303b /inflate.c | |
parent | 27ef026603319decd1b3d4d92a5d3bf21dcc2db5 (diff) | |
download | zlib-e54e1299404101a5a9d0cf5e45512b543967f958.tar.gz zlib-e54e1299404101a5a9d0cf5e45512b543967f958.tar.bz2 zlib-e54e1299404101a5a9d0cf5e45512b543967f958.zip |
Avoid shifts of negative values inflateMark().
The C standard says that bit shifts of negative integers is
undefined. This casts to unsigned values to assure a known
result.
Diffstat (limited to 'inflate.c')
-rw-r--r-- | inflate.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -1506,9 +1506,10 @@ z_streamp strm; | |||
1506 | { | 1506 | { |
1507 | struct inflate_state FAR *state; | 1507 | struct inflate_state FAR *state; |
1508 | 1508 | ||
1509 | if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16; | 1509 | if (strm == Z_NULL || strm->state == Z_NULL) |
1510 | return (long)(((unsigned long)0 - 1) << 16); | ||
1510 | state = (struct inflate_state FAR *)strm->state; | 1511 | state = (struct inflate_state FAR *)strm->state; |
1511 | return ((long)(state->back) << 16) + | 1512 | return (long)(((unsigned long)((long)state->back)) << 16) + |
1512 | (state->mode == COPY ? state->length : | 1513 | (state->mode == COPY ? state->length : |
1513 | (state->mode == MATCH ? state->was - state->length : 0)); | 1514 | (state->mode == MATCH ? state->was - state->length : 0)); |
1514 | } | 1515 | } |