diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index d26455e1301..b69ab997042 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -294,32 +294,32 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx, if (calld->send_message_blocked == false) { /* when all the send_message data is available, then modify the path * MDELEM by appending base64 encoded query to the path */ - static const int k_url_safe = 1; - static const int k_multi_line = 0; - static const char *k_query_separator = "?"; + const int k_url_safe = 1; + const int k_multi_line = 0; + const char *k_query_separator = "?"; + const size_t k_query_separator_len = GPR_ARRAY_SIZE(k_query_separator); grpc_slice path_slice = GRPC_MDVALUE(op->send_initial_metadata->idx.named.path->md); /* sum up individual component's lengths and allocate enough memory to * hold combined path+query */ size_t estimated_len = GRPC_SLICE_LENGTH(path_slice); - estimated_len += strlen(k_query_separator); + estimated_len += k_query_separator_len; estimated_len += grpc_base64_estimate_encoded_size( op->send_message->length, k_url_safe, k_multi_line); estimated_len += 1; /* for the trailing 0 */ grpc_slice path_with_query_slice = grpc_slice_malloc(estimated_len); /* memcopy individual pieces into this slice */ - char *write_ptr = (char *)GRPC_SLICE_START_PTR(path_with_query_slice); - - char *original_path = (char *)GRPC_SLICE_START_PTR(path_slice); + uint8_t *write_ptr = (uint8_t *)GRPC_SLICE_START_PTR(path_with_query_slice); + uint8_t *original_path = (uint8_t *)GRPC_SLICE_START_PTR(path_slice); memcpy(write_ptr, original_path, GRPC_SLICE_LENGTH(path_slice)); - write_ptr += (int)GRPC_SLICE_LENGTH(path_slice); + write_ptr += GRPC_SLICE_LENGTH(path_slice); - memcpy(write_ptr, k_query_separator, strlen(k_query_separator)); - write_ptr += strlen(k_query_separator); + memcpy(write_ptr, k_query_separator, k_query_separator_len); + write_ptr += k_query_separator_len; - grpc_base64_encode_core(write_ptr, calld->payload_bytes, + grpc_base64_encode_core((char *)write_ptr, calld->payload_bytes, op->send_message->length, k_url_safe, k_multi_line); @@ -327,9 +327,9 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx, */ char *t = (char *)GRPC_SLICE_START_PTR(path_with_query_slice); size_t path_length = strlen(t) + 1; - *(t + path_length) = 0; + *(t + path_length) = '\0'; path_with_query_slice = - grpc_slice_sub(path_with_query_slice, 0, path_length); + grpc_slice_sub_no_ref(path_with_query_slice, 0, path_length); /* substitute previous path with the new path+query */ grpc_mdelem mdelem_path_and_query = grpc_mdelem_from_slices( diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index 31149aa1169..4ca4602cba0 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -200,9 +200,9 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, } else if (*calld->recv_cacheable_request == true) { /* We have a cacheable request made with GET verb. The path contains the * query parameter which is base64 encoded request payload. */ - static const char *k_query_separator = "?"; + const char *k_query_separator = "?"; grpc_slice path_slice = GRPC_MDVALUE(b->idx.named.path->md); - char *path_ptr = (char *)GRPC_SLICE_START_PTR(path_slice); + uint8_t *path_ptr = (uint8_t *)GRPC_SLICE_START_PTR(path_slice); size_t path_length = GRPC_SLICE_LENGTH(path_slice); /* offset of the character '?' */ size_t offset = 0; @@ -220,7 +220,7 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, mdelem_path_without_query); /* decode payload from query and add to the slice buffer to be returned */ - static const int k_url_safe = 1; + const int k_url_safe = 1; grpc_slice_buffer_add( &calld->read_slice_buffer, grpc_base64_decode(exec_ctx,