summaryrefslogtreecommitdiff
path: root/inflate.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2015-09-05 17:45:55 -0700
committerHans Kristian Rosbach <hk-github@circlestorm.org>2020-10-09 11:30:04 +0200
commite6a27bda7f73beb5f7c638ef5db9846b3d51941f (patch)
treea67e19836692e004ac6054f23daa7849ba437a0a /inflate.c
parentb5b48c1883903ccbab7ec61d06352cdb9328dc0f (diff)
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.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/inflate.c b/inflate.c
index 36fc79c..96f7443 100644
--- a/inflate.c
+++ b/inflate.c
@@ -1337,7 +1337,8 @@ long Z_EXPORT PREFIX(inflateMark)(PREFIX3(stream) *strm) {
return -65536;
INFLATE_MARK_HOOK(strm); /* hook for IBM Z DFLTCC */
state = (struct inflate_state *)strm->state;
- return ((long)(state->back) << 16) + (state->mode == COPY ? state->length :
+ return (long)(((unsigned long)((long)state->back)) << 16) +
+ (state->mode == COPY ? state->length :
(state->mode == MATCH ? state->was - state->length : 0));
}