aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/compression/message_compress.c
diff options
context:
space:
mode:
authorGravatar Julien Boeuf <jboeuf@google.com>2015-09-15 15:20:26 -0700
committerGravatar Julien Boeuf <jboeuf@google.com>2015-09-15 15:20:26 -0700
commitfd2f7331fa97f735879a8759ac9fc8591969011b (patch)
treeda031f982ee5d1d21fd71e6c4bc9d80365c7d6e2 /src/core/compression/message_compress.c
parent1928d496a237c3850365e2557ae41ae73125fc80 (diff)
parent9ed4be48955e3b65b0540f70060b7191d8c1eef1 (diff)
Merge branch 'master' of github.com:grpc/grpc into core_creds_plugin
Diffstat (limited to 'src/core/compression/message_compress.c')
-rw-r--r--src/core/compression/message_compress.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/core/compression/message_compress.c b/src/core/compression/message_compress.c
index 7856f40dd1..01db7134c3 100644
--- a/src/core/compression/message_compress.c
+++ b/src/core/compression/message_compress.c
@@ -49,19 +49,23 @@ static int zlib_body(z_stream *zs, gpr_slice_buffer *input,
int flush;
size_t i;
gpr_slice outbuf = gpr_slice_malloc(OUTPUT_BLOCK_SIZE);
+ const uInt uint_max = ~(uInt)0;
- zs->avail_out = GPR_SLICE_LENGTH(outbuf);
+ GPR_ASSERT(GPR_SLICE_LENGTH(outbuf) <= uint_max);
+ zs->avail_out = (uInt)GPR_SLICE_LENGTH(outbuf);
zs->next_out = GPR_SLICE_START_PTR(outbuf);
flush = Z_NO_FLUSH;
for (i = 0; i < input->count; i++) {
if (i == input->count - 1) flush = Z_FINISH;
- zs->avail_in = GPR_SLICE_LENGTH(input->slices[i]);
+ GPR_ASSERT(GPR_SLICE_LENGTH(input->slices[i]) <= uint_max);
+ zs->avail_in = (uInt)GPR_SLICE_LENGTH(input->slices[i]);
zs->next_in = GPR_SLICE_START_PTR(input->slices[i]);
do {
if (zs->avail_out == 0) {
gpr_slice_buffer_add_indexed(output, outbuf);
outbuf = gpr_slice_malloc(OUTPUT_BLOCK_SIZE);
- zs->avail_out = GPR_SLICE_LENGTH(outbuf);
+ GPR_ASSERT(GPR_SLICE_LENGTH(outbuf) <= uint_max);
+ zs->avail_out = (uInt)GPR_SLICE_LENGTH(outbuf);
zs->next_out = GPR_SLICE_START_PTR(outbuf);
}
r = flate(zs, flush);