]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Avoid shifts of negative values inflateMark().
authorMark Adler <madler@alumni.caltech.edu>
Sun, 6 Sep 2015 00:45:55 +0000 (17:45 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 9 Oct 2020 09:30:04 +0000 (11:30 +0200)
The C standard says that bit shifts of negative integers is
undefined.  This casts to unsigned values to assure a known
result.

inflate.c

index 36fc79c5f6a23ec7d46f5f0bf651d16a5408b3fb..96f7443e1cae700b132ad289dd6066bfdbe5ea3a 100644 (file)
--- 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));
 }