aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/transport
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-02-18 14:16:15 -0800
committerGravatar Craig Tiller <ctiller@google.com>2015-02-18 14:16:15 -0800
commit9be83eec1de2932946d61b774788ca18fb41e2fe (patch)
treef8672252e92ceff39ee7eccc571c31a33cf548eb /test/core/transport
parentefad8fadd36899ff98ff616c349d181f2f1e4004 (diff)
Fix use-after-free.
Transport and channel have different lifetimes, but share a metadata context. Make the metadata context ref counted, and have transport take a ref.
Diffstat (limited to 'test/core/transport')
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.c2
-rw-r--r--test/core/transport/chttp2/hpack_table_test.c6
-rw-r--r--test/core/transport/chttp2/stream_encoder_test.c2
-rw-r--r--test/core/transport/metadata_test.c18
-rw-r--r--test/core/transport/transport_end2end_tests.c2
5 files changed, 15 insertions, 15 deletions
diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c
index edab37b687..86c6bb1f56 100644
--- a/test/core/transport/chttp2/hpack_parser_test.c
+++ b/test/core/transport/chttp2/hpack_parser_test.c
@@ -214,7 +214,7 @@ static void test_vectors(grpc_slice_split_mode mode) {
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_mdctx_orphan(mdctx);
+ grpc_mdctx_unref(mdctx);
}
int main(int argc, char **argv) {
diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c
index f3da9f0d49..d1e5f0829a 100644
--- a/test/core/transport/chttp2/hpack_table_test.c
+++ b/test/core/transport/chttp2/hpack_table_test.c
@@ -126,7 +126,7 @@ static void test_static_lookup(void) {
assert_index(&tbl, 61, "www-authenticate", "");
grpc_chttp2_hptbl_destroy(&tbl);
- grpc_mdctx_orphan(mdctx);
+ grpc_mdctx_unref(mdctx);
}
static void test_many_additions(void) {
@@ -158,7 +158,7 @@ static void test_many_additions(void) {
}
grpc_chttp2_hptbl_destroy(&tbl);
- grpc_mdctx_orphan(mdctx);
+ grpc_mdctx_unref(mdctx);
}
static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl *tbl,
@@ -262,7 +262,7 @@ static void test_find(void) {
GPR_ASSERT(r.has_value == 0);
grpc_chttp2_hptbl_destroy(&tbl);
- grpc_mdctx_orphan(mdctx);
+ grpc_mdctx_unref(mdctx);
}
int main(int argc, char **argv) {
diff --git a/test/core/transport/chttp2/stream_encoder_test.c b/test/core/transport/chttp2/stream_encoder_test.c
index 3013533f9b..5c7801079f 100644
--- a/test/core/transport/chttp2/stream_encoder_test.c
+++ b/test/core/transport/chttp2/stream_encoder_test.c
@@ -309,7 +309,7 @@ static void run_test(void (*test)(), const char *name) {
grpc_sopb_init(&g_sopb);
test();
grpc_chttp2_hpack_compressor_destroy(&g_compressor);
- grpc_mdctx_orphan(g_mdctx);
+ grpc_mdctx_unref(g_mdctx);
grpc_sopb_destroy(&g_sopb);
}
diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c
index d003582a2f..f345cebdb6 100644
--- a/test/core/transport/metadata_test.c
+++ b/test/core/transport/metadata_test.c
@@ -52,7 +52,7 @@ static void test_no_op(void) {
LOG_TEST();
ctx = grpc_mdctx_create();
- grpc_mdctx_orphan(ctx);
+ grpc_mdctx_unref(ctx);
}
static void test_create_string(void) {
@@ -71,7 +71,7 @@ static void test_create_string(void) {
GPR_ASSERT(gpr_slice_str_cmp(s3->slice, "very much not hello") == 0);
grpc_mdstr_unref(s1);
grpc_mdstr_unref(s2);
- grpc_mdctx_orphan(ctx);
+ grpc_mdctx_unref(ctx);
grpc_mdstr_unref(s3);
}
@@ -95,7 +95,7 @@ static void test_create_metadata(void) {
grpc_mdelem_unref(m1);
grpc_mdelem_unref(m2);
grpc_mdelem_unref(m3);
- grpc_mdctx_orphan(ctx);
+ grpc_mdctx_unref(ctx);
}
static void test_create_many_ephemeral_metadata(void) {
@@ -116,7 +116,7 @@ static void test_create_many_ephemeral_metadata(void) {
/* capacity should not grow */
GPR_ASSERT(mdtab_capacity_before ==
grpc_mdctx_get_mdtab_capacity_test_only(ctx));
- grpc_mdctx_orphan(ctx);
+ grpc_mdctx_unref(ctx);
}
static void test_create_many_persistant_metadata(void) {
@@ -145,7 +145,7 @@ static void test_create_many_persistant_metadata(void) {
for (i = 0; i < MANY; i++) {
grpc_mdelem_unref(created[i]);
}
- grpc_mdctx_orphan(ctx);
+ grpc_mdctx_unref(ctx);
gpr_free(created);
}
@@ -171,7 +171,7 @@ static void test_spin_creating_the_same_thing(void) {
GPR_ASSERT(grpc_mdctx_get_mdtab_count_test_only(ctx) == 1);
GPR_ASSERT(grpc_mdctx_get_mdtab_free_test_only(ctx) == 1);
- grpc_mdctx_orphan(ctx);
+ grpc_mdctx_unref(ctx);
}
static void test_things_stick_around(void) {
@@ -218,7 +218,7 @@ static void test_things_stick_around(void) {
}
}
- grpc_mdctx_orphan(ctx);
+ grpc_mdctx_unref(ctx);
gpr_free(strs);
gpr_free(shuf);
}
@@ -245,7 +245,7 @@ static void test_slices_work(void) {
gpr_slice_unref(slice);
grpc_mdstr_unref(str);
- grpc_mdctx_orphan(ctx);
+ grpc_mdctx_unref(ctx);
}
static void test_base64_and_huffman_works(void) {
@@ -264,7 +264,7 @@ static void test_base64_and_huffman_works(void) {
gpr_slice_unref(slice2);
grpc_mdstr_unref(str);
- grpc_mdctx_orphan(ctx);
+ grpc_mdctx_unref(ctx);
}
int main(int argc, char **argv) {
diff --git a/test/core/transport/transport_end2end_tests.c b/test/core/transport/transport_end2end_tests.c
index 6a0848fa97..6d13bf1f8c 100644
--- a/test/core/transport/transport_end2end_tests.c
+++ b/test/core/transport/transport_end2end_tests.c
@@ -927,7 +927,7 @@ void grpc_transport_end2end_tests(grpc_transport_test_config *config) {
test_request_with_flow_ctl_cb(config, interesting_message_lengths[i]);
}
- grpc_mdctx_orphan(g_metadata_context);
+ grpc_mdctx_unref(g_metadata_context);
gpr_log(GPR_INFO, "tests completed ok");
}