diff options
author | 2015-07-21 16:22:58 -0700 | |
---|---|---|
committer | 2015-07-21 16:22:58 -0700 | |
commit | 1c604fd4f54e0e5744a357818c1782ff7877844e (patch) | |
tree | 22b7a83a7ed42288492685f4b37bce7539e66b1c /src/core/surface | |
parent | c0a09015b17d8db1ea6bee0cba5d868c7f6f6fca (diff) |
Fixed buggy grpc_compression_algorithm_parse
Diffstat (limited to 'src/core/surface')
-rw-r--r-- | src/core/surface/call.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/surface/call.c b/src/core/surface/call.c index bb1ed809f8..54f10261e3 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -495,7 +495,8 @@ static void set_encodings_accepted_by_peer(grpc_call *call, for (i = 0; i < accept_encoding_parts.count; i++) { const gpr_slice* slice = &accept_encoding_parts.slices[i]; if (grpc_compression_algorithm_parse( - (const char *)GPR_SLICE_START_PTR(*slice), &algorithm)) { + (const char *)GPR_SLICE_START_PTR(*slice), GPR_SLICE_LENGTH(*slice), + &algorithm)) { GPR_BITSET(&call->encodings_accepted_by_peer, algorithm); } else { /* TODO(dgq): it'd be nice to have a slice-to-cstr function to easily @@ -1344,10 +1345,12 @@ static gpr_uint32 decode_compression(grpc_mdelem *md) { grpc_compression_algorithm algorithm; void *user_data = grpc_mdelem_get_user_data(md, destroy_compression); if (user_data) { - algorithm = ((grpc_compression_level)(gpr_intptr)user_data) - COMPRESS_OFFSET; + algorithm = + ((grpc_compression_level)(gpr_intptr)user_data) - COMPRESS_OFFSET; } else { const char *md_c_str = grpc_mdstr_as_c_string(md->value); - if (!grpc_compression_algorithm_parse(md_c_str, &algorithm)) { + if (!grpc_compression_algorithm_parse(md_c_str, strlen(md_c_str), + &algorithm)) { gpr_log(GPR_ERROR, "Invalid compression algorithm: '%s'", md_c_str); assert(0); } |