summaryrefslogtreecommitdiff
path: root/src/third_party/zlib-1.2.8
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2015-10-07 19:43:21 -0400
committerMathias Stearn <mathias@10gen.com>2015-10-12 12:35:37 -0400
commite59924200bd5754698b359c07d4858f05e920f80 (patch)
tree499b625b2804d4174426ecc2c0a5d32732358b96 /src/third_party/zlib-1.2.8
parentcc1f48bce42728f3af21e8c6d3a9766f3675ac8a (diff)
downloadmongo-e59924200bd5754698b359c07d4858f05e920f80.tar.gz
SERVER-20664 Pull in zlib -Wshift-negative-value fixes
This is just cherry picking the following two commits from the zlib repo: https://github.com/madler/zlib/commit/e54e1299404101a5a9d0cf5e45512b543967f958 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. ------- https://github.com/madler/zlib/commit/44ae761dc2047038dc42a7e5a162d042fc392d2b Clean up portability for shifts and integer sizes.
Diffstat (limited to 'src/third_party/zlib-1.2.8')
-rw-r--r--src/third_party/zlib-1.2.8/adler32.c4
-rw-r--r--src/third_party/zlib-1.2.8/inflate.c7
-rw-r--r--src/third_party/zlib-1.2.8/zlib.h2
3 files changed, 7 insertions, 6 deletions
diff --git a/src/third_party/zlib-1.2.8/adler32.c b/src/third_party/zlib-1.2.8/adler32.c
index a868f073d8a..cfacc88cde3 100644
--- a/src/third_party/zlib-1.2.8/adler32.c
+++ b/src/third_party/zlib-1.2.8/adler32.c
@@ -11,7 +11,7 @@
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
-#define BASE 65521 /* largest prime smaller than 65536 */
+#define BASE 65521U /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
@@ -156,7 +156,7 @@ local uLong adler32_combine_(adler1, adler2, len2)
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 >= BASE) sum1 -= BASE;
if (sum1 >= BASE) sum1 -= BASE;
- if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
+ if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
if (sum2 >= BASE) sum2 -= BASE;
return sum1 | (sum2 << 16);
}
diff --git a/src/third_party/zlib-1.2.8/inflate.c b/src/third_party/zlib-1.2.8/inflate.c
index 870f89bb4d3..83f5e044f04 100644
--- a/src/third_party/zlib-1.2.8/inflate.c
+++ b/src/third_party/zlib-1.2.8/inflate.c
@@ -243,7 +243,7 @@ int value;
}
if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
value &= (1L << bits) - 1;
- state->hold += value << state->bits;
+ state->hold += (unsigned)value << state->bits;
state->bits += bits;
return Z_OK;
}
@@ -1504,9 +1504,10 @@ z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
+ if (strm == Z_NULL || strm->state == Z_NULL)
+ return (long)(((unsigned long)0 - 1) << 16);
state = (struct inflate_state FAR *)strm->state;
- return ((long)(state->back) << 16) +
+ return (long)(((unsigned long)((long)state->back)) << 16) +
(state->mode == COPY ? state->length :
(state->mode == MATCH ? state->was - state->length : 0));
}
diff --git a/src/third_party/zlib-1.2.8/zlib.h b/src/third_party/zlib-1.2.8/zlib.h
index 3e0c7672ac5..93efb6984cc 100644
--- a/src/third_party/zlib-1.2.8/zlib.h
+++ b/src/third_party/zlib-1.2.8/zlib.h
@@ -956,7 +956,7 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
location in the input stream can be determined from avail_in and data_type
as noted in the description for the Z_BLOCK flush parameter for inflate.
- inflateMark returns the value noted above or -1 << 16 if the provided
+ inflateMark returns the value noted above or -65536 if the provided
source stream state was inconsistent.
*/