aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/transport/chttp2/frame_goaway.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/transport/chttp2/frame_goaway.c
parent1928d496a237c3850365e2557ae41ae73125fc80 (diff)
parent9ed4be48955e3b65b0540f70060b7191d8c1eef1 (diff)
Merge branch 'master' of github.com:grpc/grpc into core_creds_plugin
Diffstat (limited to 'src/core/transport/chttp2/frame_goaway.c')
-rw-r--r--src/core/transport/chttp2/frame_goaway.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/core/transport/chttp2/frame_goaway.c b/src/core/transport/chttp2/frame_goaway.c
index 1ccbba840c..09d4da234c 100644
--- a/src/core/transport/chttp2/frame_goaway.c
+++ b/src/core/transport/chttp2/frame_goaway.c
@@ -136,14 +136,15 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_DEBUG:
- memcpy(p->debug_data + p->debug_pos, cur, end - cur);
- p->debug_pos += end - cur;
+ memcpy(p->debug_data + p->debug_pos, cur, (size_t)(end - cur));
+ GPR_ASSERT(end - cur < GPR_UINT32_MAX - p->debug_pos);
+ p->debug_pos += (gpr_uint32)(end - cur);
p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
if (is_last) {
transport_parsing->goaway_received = 1;
transport_parsing->goaway_last_stream_index = p->last_stream_id;
gpr_slice_unref(transport_parsing->goaway_text);
- transport_parsing->goaway_error = p->error_code;
+ transport_parsing->goaway_error = (grpc_status_code)p->error_code;
transport_parsing->goaway_text =
gpr_slice_new(p->debug_data, p->debug_length, gpr_free);
p->debug_data = NULL;
@@ -160,12 +161,14 @@ void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code,
gpr_slice_buffer *slice_buffer) {
gpr_slice header = gpr_slice_malloc(9 + 4 + 4);
gpr_uint8 *p = GPR_SLICE_START_PTR(header);
- gpr_uint32 frame_length = 4 + 4 + GPR_SLICE_LENGTH(debug_data);
+ gpr_uint32 frame_length;
+ GPR_ASSERT(GPR_SLICE_LENGTH(debug_data) < GPR_UINT32_MAX - 4 - 4);
+ frame_length = 4 + 4 + (gpr_uint32)GPR_SLICE_LENGTH(debug_data);
/* frame header: length */
- *p++ = frame_length >> 16;
- *p++ = frame_length >> 8;
- *p++ = frame_length;
+ *p++ = (gpr_uint8)(frame_length >> 16);
+ *p++ = (gpr_uint8)(frame_length >> 8);
+ *p++ = (gpr_uint8)(frame_length);
/* frame header: type */
*p++ = GRPC_CHTTP2_FRAME_GOAWAY;
/* frame header: flags */
@@ -176,15 +179,15 @@ void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code,
*p++ = 0;
*p++ = 0;
/* payload: last stream id */
- *p++ = last_stream_id >> 24;
- *p++ = last_stream_id >> 16;
- *p++ = last_stream_id >> 8;
- *p++ = last_stream_id;
+ *p++ = (gpr_uint8)(last_stream_id >> 24);
+ *p++ = (gpr_uint8)(last_stream_id >> 16);
+ *p++ = (gpr_uint8)(last_stream_id >> 8);
+ *p++ = (gpr_uint8)(last_stream_id);
/* payload: error code */
- *p++ = error_code >> 24;
- *p++ = error_code >> 16;
- *p++ = error_code >> 8;
- *p++ = error_code;
+ *p++ = (gpr_uint8)(error_code >> 24);
+ *p++ = (gpr_uint8)(error_code >> 16);
+ *p++ = (gpr_uint8)(error_code >> 8);
+ *p++ = (gpr_uint8)(error_code);
GPR_ASSERT(p == GPR_SLICE_END_PTR(header));
gpr_slice_buffer_add(slice_buffer, header);
gpr_slice_buffer_add(slice_buffer, debug_data);