Catch bad timeout handling

pull/4356/head
Craig Tiller 9 years ago
parent f4786c2361
commit 25fd57117d
  1. 2
      src/core/transport/chttp2/parsing.c
  2. 2
      test/core/bad_client/tests/bad_timeout.headers
  3. 16
      test/core/bad_client/tests/headers.c
  4. 12
      test/core/bad_client/tests/simple_request.c

@ -604,7 +604,7 @@ static void on_initial_header(void *tp, grpc_mdelem *md) {
cached_timeout)) {
gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'",
grpc_mdstr_as_c_string(md->value));
*cached_timeout = gpr_inf_future(GPR_CLOCK_REALTIME);
*cached_timeout = gpr_inf_future(GPR_TIMESPAN);
}
grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
}

@ -0,0 +1,2 @@
# a badly encoded timeout value
grpc-timeout: 15 seconds

@ -217,5 +217,21 @@ int main(int argc, char **argv) {
"\x00\x00\x00\x01\x39\x67\xed\x1d\x64",
GRPC_BAD_CLIENT_DISCONNECT);
/* a badly encoded timeout value */
GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR
"\x00\x00\x19\x01\x04\x00\x00\x00\x01"
"\x10\x0cgrpc-timeout\x0a"
"15 seconds",
GRPC_BAD_CLIENT_DISCONNECT);
/* a badly encoded timeout value: twice (catches caching) */
GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR
"\x00\x00\x19\x01\x04\x00\x00\x00\x01"
"\x10\x0cgrpc-timeout\x0a"
"15 seconds"
"\x00\x00\x19\x01\x04\x00\x00\x00\x03"
"\x10\x0cgrpc-timeout\x0a"
"15 seconds",
GRPC_BAD_CLIENT_DISCONNECT);
return 0;
}

@ -85,8 +85,18 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq) {
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
/* partial http2 header prefixes */
/* basic request: check that things are working */
GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR, 0);
/* push an illegal data frame */
GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR
"\x00\x00\x05\x00\x00\x00\x00\x00\x01"
"\x34\x00\x00\x00\x00",
0);
/* push a data frame with bad flags */
GRPC_RUN_BAD_CLIENT_TEST(verifier,
PFX_STR "\x00\x00\x00\x00\x02\x00\x00\x00\x01", 0);
return 0;
}

Loading…
Cancel
Save