aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Muxi Yan <muxi@users.noreply.github.com>2016-11-23 18:50:38 -0800
committerGravatar GitHub <noreply@github.com>2016-11-23 18:50:38 -0800
commitdc2111ec70c2545fd811ebb7e52157e0d848ccf2 (patch)
treefbde3d9a8b51a70e624a1e8130d79e70b9d44c10
parent8a4ac886e4da6b278f30115431f090661bd1576b (diff)
parentd7425740045acb658c365f905c4988460628ef33 (diff)
Merge pull request #8735 from muxi/fix-error-status-popup-v10x
Backport: Send RST_STREAM from client when it receives trailing metadata without the corresponding RST_STREAM
-rw-r--r--src/core/ext/transport/chttp2/transport/parsing.c15
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer_corpus/server_hanging_response_1_headerbin0 -> 18 bytes
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer_corpus/server_hanging_response_2_header2bin0 -> 27 bytes
-rwxr-xr-xtest/core/end2end/fuzzers/generate_client_examples_of_bad_closing_streams.py49
-rw-r--r--tools/run_tests/tests.json38
5 files changed, 100 insertions, 2 deletions
diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c
index e1fc0ddee2..cbbffc5a61 100644
--- a/src/core/ext/transport/chttp2/transport/parsing.c
+++ b/src/core/ext/transport/chttp2/transport/parsing.c
@@ -253,8 +253,19 @@ void grpc_chttp2_publish_reads(
}
if (stream_parsing->received_close) {
- grpc_chttp2_mark_stream_closed(exec_ctx, transport_global, stream_global,
- 1, 0, GRPC_ERROR_NONE);
+ if (transport_global->is_client && !stream_global->write_closed) {
+ gpr_slice_buffer_add(
+ &transport_global->qbuf,
+ grpc_chttp2_rst_stream_create(transport_parsing->incoming_stream_id,
+ GRPC_CHTTP2_NO_ERROR,
+ &stream_parsing->stats.outgoing));
+ grpc_chttp2_initiate_write(exec_ctx, transport_global, false, "rst");
+ grpc_chttp2_mark_stream_closed(exec_ctx, transport_global,
+ stream_global, 1, 1, GRPC_ERROR_NONE);
+ } else {
+ grpc_chttp2_mark_stream_closed(exec_ctx, transport_global,
+ stream_global, 1, 0, GRPC_ERROR_NONE);
+ }
}
}
}
diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/server_hanging_response_1_header b/test/core/end2end/fuzzers/client_fuzzer_corpus/server_hanging_response_1_header
new file mode 100644
index 0000000000..d2abd17464
--- /dev/null
+++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/server_hanging_response_1_header
Binary files differ
diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/server_hanging_response_2_header2 b/test/core/end2end/fuzzers/client_fuzzer_corpus/server_hanging_response_2_header2
new file mode 100644
index 0000000000..752af468ba
--- /dev/null
+++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/server_hanging_response_2_header2
Binary files differ
diff --git a/test/core/end2end/fuzzers/generate_client_examples_of_bad_closing_streams.py b/test/core/end2end/fuzzers/generate_client_examples_of_bad_closing_streams.py
new file mode 100755
index 0000000000..d80c1e0442
--- /dev/null
+++ b/test/core/end2end/fuzzers/generate_client_examples_of_bad_closing_streams.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python2.7
+# Copyright 2015, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import os
+import sys
+
+os.chdir(os.path.dirname(sys.argv[0]))
+
+streams = {
+ 'server_hanging_response_1_header': (
+ [0,0,0,4,0,0,0,0,0] + # settings frame
+ [0,0,0,1,5,0,0,0,1] # trailers
+ ),
+ 'server_hanging_response_2_header2': (
+ [0,0,0,4,0,0,0,0,0] + # settings frame
+ [0,0,0,1,4,0,0,0,1] + # headers
+ [0,0,0,1,5,0,0,0,1] # trailers
+ ),
+}
+
+for name, stream in streams.items():
+ open('client_fuzzer_corpus/%s' % name, 'w').write(bytearray(stream))
diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json
index 88869e6497..55fc0e38d1 100644
--- a/tools/run_tests/tests.json
+++ b/tools/run_tests/tests.json
@@ -62716,6 +62716,44 @@
},
{
"args": [
+ "test/core/end2end/fuzzers/client_fuzzer_corpus/server_hanging_response_1_header"
+ ],
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [
+ "tsan"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "client_fuzzer_one_entry",
+ "platforms": [
+ "linux"
+ ],
+ "uses_polling": false
+ },
+ {
+ "args": [
+ "test/core/end2end/fuzzers/client_fuzzer_corpus/server_hanging_response_2_header2"
+ ],
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [
+ "tsan"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "client_fuzzer_one_entry",
+ "platforms": [
+ "linux"
+ ],
+ "uses_polling": false
+ },
+ {
+ "args": [
"test/core/end2end/fuzzers/client_fuzzer_corpus/settings_frame_1.bin"
],
"ci_platforms": [