diff options
-rw-r--r-- | src/core/lib/surface/validate_metadata.c | 7 | ||||
-rw-r--r-- | test/core/end2end/invalid_call_argument_test.c | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/core/lib/surface/validate_metadata.c b/src/core/lib/surface/validate_metadata.c index 8c11345c65..7ec9137265 100644 --- a/src/core/lib/surface/validate_metadata.c +++ b/src/core/lib/surface/validate_metadata.c @@ -73,8 +73,11 @@ grpc_error *grpc_validate_header_key_is_legal(grpc_slice slice) { 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0x00, 0x00, 0x00, 0x80, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - if (GRPC_SLICE_LENGTH(slice) == 0 || GRPC_SLICE_START_PTR(slice)[0] == ':') { - return 0; + if (GRPC_SLICE_LENGTH(slice) == 0) { + return GRPC_ERROR_CREATE("Metadata keys cannot be zero length"); + } + if (GRPC_SLICE_START_PTR(slice)[0] == ':') { + return GRPC_ERROR_CREATE("Metadata keys cannot start with :"); } return conforms_to(slice, legal_header_bits, "Illegal header key"); } diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index 9067b24168..a9d0287952 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -597,6 +597,7 @@ static void test_invalid_initial_metadata_reserved_key() { int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); + test_invalid_initial_metadata_reserved_key(); test_non_null_reserved_on_start_batch(); test_non_null_reserved_on_op(); test_send_initial_metadata_more_than_once(); @@ -616,7 +617,6 @@ int main(int argc, char **argv) { test_send_server_status_twice(); test_recv_close_on_server_with_invalid_flags(); test_recv_close_on_server_twice(); - test_invalid_initial_metadata_reserved_key(); grpc_shutdown(); return 0; |