Fix metadata validation

reviewable/pr8842/r4
Craig Tiller 8 years ago
parent 5ffd766a5e
commit 296c7bb8fa
  1. 7
      src/core/lib/surface/validate_metadata.c
  2. 2
      test/core/end2end/invalid_call_argument_test.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");
}

@ -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;

Loading…
Cancel
Save