aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/lib/surface/validate_metadata.c2
-rw-r--r--test/core/end2end/invalid_call_argument_test.c24
2 files changed, 25 insertions, 1 deletions
diff --git a/src/core/lib/surface/validate_metadata.c b/src/core/lib/surface/validate_metadata.c
index 84f0a083bc..f49dd8584b 100644
--- a/src/core/lib/surface/validate_metadata.c
+++ b/src/core/lib/surface/validate_metadata.c
@@ -53,7 +53,7 @@ int grpc_header_key_is_legal(const char *key, size_t length) {
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 (length == 0) {
+ if (length == 0 || key[0] == ':') {
return 0;
}
return conforms_to(key, length, legal_header_bits);
diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c
index 765b6ad1be..d974d2c8ff 100644
--- a/test/core/end2end/invalid_call_argument_test.c
+++ b/test/core/end2end/invalid_call_argument_test.c
@@ -573,6 +573,29 @@ static void test_recv_close_on_server_twice() {
cleanup_test();
}
+static void test_invalid_initial_metadata_reserved_key() {
+ gpr_log(GPR_INFO, "test_invalid_initial_metadata_reserved_key");
+
+ grpc_metadata metadata;
+ metadata.key = ":start_with_colon";
+ metadata.value = "value";
+ metadata.value_length = 6;
+
+ grpc_op *op;
+ prepare_test(1);
+ op = g_state.ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 1;
+ op->data.send_initial_metadata.metadata = &metadata;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ GPR_ASSERT(GRPC_CALL_ERROR_INVALID_METADATA ==
+ grpc_call_start_batch(g_state.call, g_state.ops,
+ (size_t)(op - g_state.ops), tag(1), NULL));
+ cleanup_test();
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_init();
@@ -595,6 +618,7 @@ 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;