From 795764bf3afcc482917b250193166667e26185c0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 11 Dec 2015 08:56:09 -0800 Subject: [PATCH 1/3] Hit a few more paths in http_server_filter.c, sockaddr_resolver.c --- Makefile | 21 ++ test/core/bad_client/gen_build_yaml.py | 1 + test/core/bad_client/tests/badreq.c | 100 ++++++++++ .../bad_client/tests/badreq_2path.headers | 13 ++ .../tests/badreq_content_type.headers | 11 ++ test/core/bad_client/tests/badreq_te.headers | 11 ++ .../resolvers/sockaddr_resolver_test.c | 1 + tools/run_tests/sources_and_headers.json | 15 ++ tools/run_tests/tests.json | 18 ++ vsprojects/buildtests_c.sln | 28 +++ .../badreq_bad_client_test.vcxproj | 187 ++++++++++++++++++ .../badreq_bad_client_test.vcxproj.filters | 24 +++ 12 files changed, 430 insertions(+) create mode 100644 test/core/bad_client/tests/badreq.c create mode 100644 test/core/bad_client/tests/badreq_2path.headers create mode 100644 test/core/bad_client/tests/badreq_content_type.headers create mode 100644 test/core/bad_client/tests/badreq_te.headers create mode 100644 vsprojects/vcxproj/test/badreq_bad_client_test/badreq_bad_client_test.vcxproj create mode 100644 vsprojects/vcxproj/test/badreq_bad_client_test/badreq_bad_client_test.vcxproj.filters diff --git a/Makefile b/Makefile index 7f2c6abc4fd..4b0e9c4ae9c 100644 --- a/Makefile +++ b/Makefile @@ -1793,6 +1793,7 @@ h2_uds+poll_shutdown_finishes_tags_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_s h2_uds+poll_simple_delayed_request_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_simple_delayed_request_nosec_test h2_uds+poll_simple_request_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_simple_request_nosec_test h2_uds+poll_trailing_metadata_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_trailing_metadata_nosec_test +badreq_bad_client_test: $(BINDIR)/$(CONFIG)/badreq_bad_client_test connection_prefix_bad_client_test: $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test headers_bad_client_test: $(BINDIR)/$(CONFIG)/headers_bad_client_test initial_settings_frame_bad_client_test: $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test @@ -2887,6 +2888,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/h2_uds+poll_simple_delayed_request_nosec_test \ $(BINDIR)/$(CONFIG)/h2_uds+poll_simple_request_nosec_test \ $(BINDIR)/$(CONFIG)/h2_uds+poll_trailing_metadata_nosec_test \ + $(BINDIR)/$(CONFIG)/badreq_bad_client_test \ $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test \ $(BINDIR)/$(CONFIG)/headers_bad_client_test \ $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test \ @@ -4870,6 +4872,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/h2_uds+poll_simple_request_nosec_test || ( echo test h2_uds+poll_simple_request_nosec_test failed ; exit 1 ) $(E) "[RUN] Testing h2_uds+poll_trailing_metadata_nosec_test" $(Q) $(BINDIR)/$(CONFIG)/h2_uds+poll_trailing_metadata_nosec_test || ( echo test h2_uds+poll_trailing_metadata_nosec_test failed ; exit 1 ) + $(E) "[RUN] Testing badreq_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/badreq_bad_client_test || ( echo test badreq_bad_client_test failed ; exit 1 ) $(E) "[RUN] Testing connection_prefix_bad_client_test" $(Q) $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test || ( echo test connection_prefix_bad_client_test failed ; exit 1 ) $(E) "[RUN] Testing headers_bad_client_test" @@ -26087,6 +26091,23 @@ $(BINDIR)/$(CONFIG)/h2_uds+poll_trailing_metadata_nosec_test: $(LIBDIR)/$(CONFI +BADREQ_BAD_CLIENT_TEST_SRC = \ + test/core/bad_client/tests/badreq.c \ + +BADREQ_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BADREQ_BAD_CLIENT_TEST_SRC)))) +$(BINDIR)/$(CONFIG)/badreq_bad_client_test: $(BADREQ_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(BADREQ_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/badreq_bad_client_test + +$(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/badreq.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +deps_badreq_bad_client_test: $(BADREQ_BAD_CLIENT_TEST_OBJS:.o=.dep) + +ifneq ($(NO_DEPS),true) +-include $(BADREQ_BAD_CLIENT_TEST_OBJS:.o=.dep) +endif + + CONNECTION_PREFIX_BAD_CLIENT_TEST_SRC = \ test/core/bad_client/tests/connection_prefix.c \ diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py index 8e204ac2015..386a8965db9 100755 --- a/test/core/bad_client/gen_build_yaml.py +++ b/test/core/bad_client/gen_build_yaml.py @@ -40,6 +40,7 @@ default_test_options = TestOptions(False) # maps test names to options BAD_CLIENT_TESTS = { + 'badreq': default_test_options, 'connection_prefix': default_test_options, 'headers': default_test_options, 'initial_settings_frame': default_test_options, diff --git a/test/core/bad_client/tests/badreq.c b/test/core/bad_client/tests/badreq.c new file mode 100644 index 00000000000..d90388158d9 --- /dev/null +++ b/test/core/bad_client/tests/badreq.c @@ -0,0 +1,100 @@ +/* + * + * 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. + * + */ + +#include "test/core/bad_client/bad_client.h" + +#include + +#include "test/core/end2end/cq_verifier.h" +#include "src/core/surface/server.h" + +#define PFX_STR \ + "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ + "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ + +static void verifier(grpc_server *server, grpc_completion_queue *cq) { + while (grpc_server_has_open_connections(server)) { + GPR_ASSERT(grpc_completion_queue_next(cq, + GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), + NULL).type == GRPC_QUEUE_TIMEOUT); + } +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + + /* invalid content type */ + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR + "\x00\x00\xc2\x01\x04\x00\x00\x00\x01" + "\x10\x05:path\x08/foo/bar" + "\x10\x07:scheme\x04http" + "\x10\x07:method\x04POST" + "\x10\x0a:authority\x09localhost" + "\x10\x0c""content-type\x09text/html" + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" + "\x10\x02te\x08trailers" + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", + GRPC_BAD_CLIENT_DISCONNECT); + + /* invalid te */ + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR + "\x00\x00\xcb\x01\x04\x00\x00\x00\x01" + "\x10\x05:path\x08/foo/bar" + "\x10\x07:scheme\x04http" + "\x10\x07:method\x04POST" + "\x10\x0a:authority\x09localhost" + "\x10\x0c""content-type\x10""application/grpc" + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" + "\x10\x02te\x0a""frobnicate" + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", + GRPC_BAD_CLIENT_DISCONNECT); + + /* two path headers */ + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR + "\x00\x00\xd9\x01\x04\x00\x00\x00\x01" + "\x10\x05:path\x08/foo/bar" + "\x10\x05:path\x08/foo/bah" + "\x10\x07:scheme\x04http" + "\x10\x07:method\x04POST" + "\x10\x0a:authority\x09localhost" + "\x10\x0c""content-type\x10""application/grpc" + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" + "\x10\x02te\x08trailers" + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", + GRPC_BAD_CLIENT_DISCONNECT); + + return 0; +} diff --git a/test/core/bad_client/tests/badreq_2path.headers b/test/core/bad_client/tests/badreq_2path.headers new file mode 100644 index 00000000000..0441e50c8c7 --- /dev/null +++ b/test/core/bad_client/tests/badreq_2path.headers @@ -0,0 +1,13 @@ +# headers used in badreq.c +# use tools/codegen/core/gen_header_frame.py to generate the binary strings +# contained in the source code +:path: /foo/bar +:path: /foo/bah +:scheme: http +:method: POST +:authority: localhost +content-type: application/grpc +grpc-accept-encoding: identity,deflate,gzip +te: trailers +user-agent: bad-client grpc-c/0.12.0.0 (linux) + diff --git a/test/core/bad_client/tests/badreq_content_type.headers b/test/core/bad_client/tests/badreq_content_type.headers new file mode 100644 index 00000000000..ed8d798f195 --- /dev/null +++ b/test/core/bad_client/tests/badreq_content_type.headers @@ -0,0 +1,11 @@ +# headers used in badreq.c +# use tools/codegen/core/gen_header_frame.py to generate the binary strings +# contained in the source code +:path: /foo/bar +:scheme: http +:method: POST +:authority: localhost +content-type: text/html +grpc-accept-encoding: identity,deflate,gzip +te: trailers +user-agent: bad-client grpc-c/0.12.0.0 (linux) diff --git a/test/core/bad_client/tests/badreq_te.headers b/test/core/bad_client/tests/badreq_te.headers new file mode 100644 index 00000000000..012810e77dc --- /dev/null +++ b/test/core/bad_client/tests/badreq_te.headers @@ -0,0 +1,11 @@ +# headers used in badreq.c +# use tools/codegen/core/gen_header_frame.py to generate the binary strings +# contained in the source code +:path: /foo/bar +:scheme: http +:method: POST +:authority: localhost +content-type: application/grpc +grpc-accept-encoding: identity,deflate,gzip +te: frobnicate +user-agent: bad-client grpc-c/0.12.0.0 (linux) diff --git a/test/core/client_config/resolvers/sockaddr_resolver_test.c b/test/core/client_config/resolvers/sockaddr_resolver_test.c index 666e6362fef..c94e46a2c72 100644 --- a/test/core/client_config/resolvers/sockaddr_resolver_test.c +++ b/test/core/client_config/resolvers/sockaddr_resolver_test.c @@ -107,6 +107,7 @@ int main(int argc, char **argv) { test_fails(ipv6, "ipv6:[::]"); test_succeeds(ipv6, "ipv6:[::]:1234"); test_fails(ipv6, "ipv6:[::]:123456"); + test_fails(ipv6, "ipv6:www.google.com"); grpc_resolver_factory_unref(ipv4); grpc_resolver_factory_unref(ipv6); diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 7d102408181..ae554593cc7 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -14823,6 +14823,21 @@ "name": "h2_uds+poll_trailing_metadata_nosec_test", "src": [] }, + { + "deps": [ + "bad_client_test", + "gpr", + "gpr_test_util", + "grpc_test_util_unsecure", + "grpc_unsecure" + ], + "headers": [], + "language": "c", + "name": "badreq_bad_client_test", + "src": [ + "test/core/bad_client/tests/badreq.c" + ] + }, { "deps": [ "bad_client_test", diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 4ab124f5f06..49d14cfb0fd 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -16276,6 +16276,24 @@ "linux" ] }, + { + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "exclude_configs": [], + "flaky": false, + "language": "c", + "name": "badreq_bad_client_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ] + }, { "ci_platforms": [ "linux", diff --git a/vsprojects/buildtests_c.sln b/vsprojects/buildtests_c.sln index fb221ea85cb..d5ecbffcc51 100644 --- a/vsprojects/buildtests_c.sln +++ b/vsprojects/buildtests_c.sln @@ -10665,6 +10665,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "h2_uchannel_trailing_metada {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "badreq_bad_client_test", "vcxproj\test\badreq_bad_client_test\badreq_bad_client_test.vcxproj", "{8A811C28-E04E-A444-E4C1-7588DF5B90AE}" + ProjectSection(myProperties) = preProject + lib = "False" + EndProjectSection + ProjectSection(ProjectDependencies) = postProject + {BA67B418-B699-E41A-9CC4-0279C49481A5} = {BA67B418-B699-E41A-9CC4-0279C49481A5} + {0A7E7F92-FDEA-40F1-A9EC-3BA484F98BBF} = {0A7E7F92-FDEA-40F1-A9EC-3BA484F98BBF} + {46CEDFFF-9692-456A-AA24-38B5D6BCF4C5} = {46CEDFFF-9692-456A-AA24-38B5D6BCF4C5} + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037} + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "connection_prefix_bad_client_test", "vcxproj\test\connection_prefix_bad_client_test\connection_prefix_bad_client_test.vcxproj", "{AF9D0EB2-2A53-B815-3A63-E82C7F91DB29}" ProjectSection(myProperties) = preProject lib = "False" @@ -23841,6 +23853,22 @@ Global {4070A24F-256D-F437-1D6C-7D3B9509FDEC}.Release-DLL|Win32.Build.0 = Release|Win32 {4070A24F-256D-F437-1D6C-7D3B9509FDEC}.Release-DLL|x64.ActiveCfg = Release|x64 {4070A24F-256D-F437-1D6C-7D3B9509FDEC}.Release-DLL|x64.Build.0 = Release|x64 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Debug|Win32.ActiveCfg = Debug|Win32 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Debug|x64.ActiveCfg = Debug|x64 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release|Win32.ActiveCfg = Release|Win32 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release|x64.ActiveCfg = Release|x64 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Debug|Win32.Build.0 = Debug|Win32 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Debug|x64.Build.0 = Debug|x64 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release|Win32.Build.0 = Release|Win32 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release|x64.Build.0 = Release|x64 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Debug-DLL|Win32.ActiveCfg = Debug|Win32 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Debug-DLL|Win32.Build.0 = Debug|Win32 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Debug-DLL|x64.ActiveCfg = Debug|x64 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Debug-DLL|x64.Build.0 = Debug|x64 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release-DLL|Win32.ActiveCfg = Release|Win32 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release-DLL|Win32.Build.0 = Release|Win32 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release-DLL|x64.ActiveCfg = Release|x64 + {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release-DLL|x64.Build.0 = Release|x64 {AF9D0EB2-2A53-B815-3A63-E82C7F91DB29}.Debug|Win32.ActiveCfg = Debug|Win32 {AF9D0EB2-2A53-B815-3A63-E82C7F91DB29}.Debug|x64.ActiveCfg = Debug|x64 {AF9D0EB2-2A53-B815-3A63-E82C7F91DB29}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/vsprojects/vcxproj/test/badreq_bad_client_test/badreq_bad_client_test.vcxproj b/vsprojects/vcxproj/test/badreq_bad_client_test/badreq_bad_client_test.vcxproj new file mode 100644 index 00000000000..8e9314164a0 --- /dev/null +++ b/vsprojects/vcxproj/test/badreq_bad_client_test/badreq_bad_client_test.vcxproj @@ -0,0 +1,187 @@ + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {8A811C28-E04E-A444-E4C1-7588DF5B90AE} + + + + v100 + + + v110 + + + v120 + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + badreq_bad_client_test + static + Debug + Debug + + + badreq_bad_client_test + static + Debug + Debug + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + + + Console + true + false + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + + + Console + true + false + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + MultiThreaded + true + None + + + Console + true + false + true + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreaded + true + None + + + Console + true + false + true + true + + + + + + + + + {BA67B418-B699-E41A-9CC4-0279C49481A5} + + + {0A7E7F92-FDEA-40F1-A9EC-3BA484F98BBF} + + + {46CEDFFF-9692-456A-AA24-38B5D6BCF4C5} + + + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} + + + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + diff --git a/vsprojects/vcxproj/test/badreq_bad_client_test/badreq_bad_client_test.vcxproj.filters b/vsprojects/vcxproj/test/badreq_bad_client_test/badreq_bad_client_test.vcxproj.filters new file mode 100644 index 00000000000..276d660ffc6 --- /dev/null +++ b/vsprojects/vcxproj/test/badreq_bad_client_test/badreq_bad_client_test.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + test\core\bad_client\tests + + + + + + {677fb53e-e5cd-5ec5-a036-ac08770cf93c} + + + {f46c8db2-58ee-1c5a-7922-40805cc12827} + + + {6580deef-ed38-ffc5-63c7-2362cd082b46} + + + {9a11fdc5-1340-2198-93bd-55ed3187c2aa} + + + + From d56550ad6d5a81e1481b159acda0bb789c7d16ad Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 11 Dec 2015 14:20:03 -0800 Subject: [PATCH 2/3] Test invalid accept-encoding values --- test/core/bad_client/tests/badreq.c | 14 ++++++++++++++ .../core/bad_client/tests/badreq_algorithm.headers | 11 +++++++++++ 2 files changed, 25 insertions(+) create mode 100644 test/core/bad_client/tests/badreq_algorithm.headers diff --git a/test/core/bad_client/tests/badreq.c b/test/core/bad_client/tests/badreq.c index d90388158d9..3130a096540 100644 --- a/test/core/bad_client/tests/badreq.c +++ b/test/core/bad_client/tests/badreq.c @@ -96,5 +96,19 @@ int main(int argc, char **argv) { "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", GRPC_BAD_CLIENT_DISCONNECT); + /* bad accept-encoding algorithm */ + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR + "\x00\x00\xd2\x01\x04\x00\x00\x00\x01" + "\x10\x05:path\x08/foo/bar" + "\x10\x07:scheme\x04http" + "\x10\x07:method\x04POST" + "\x10\x0a:authority\x09localhost" + "\x10\x0c""content-type\x10""application/grpc" + "\x10\x14grpc-accept-encoding\x1enobody-knows-the-trouble-i-see" + "\x10\x02te\x08trailers" + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", + GRPC_BAD_CLIENT_DISCONNECT); + return 0; } diff --git a/test/core/bad_client/tests/badreq_algorithm.headers b/test/core/bad_client/tests/badreq_algorithm.headers new file mode 100644 index 00000000000..ff3e613f933 --- /dev/null +++ b/test/core/bad_client/tests/badreq_algorithm.headers @@ -0,0 +1,11 @@ +# headers used in badreq.c +# use tools/codegen/core/gen_header_frame.py to generate the binary strings +# contained in the source code +:path: /foo/bar +:scheme: http +:method: POST +:authority: localhost +content-type: application/grpc +grpc-accept-encoding: nobody-knows-the-trouble-i-see +te: trailers +user-agent: bad-client grpc-c/0.12.0.0 (linux) From 04b0494169fb14b289280622a285c6fe7a34803b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 11 Dec 2015 14:22:42 -0800 Subject: [PATCH 3/3] Test invalid grpc-encoding values --- test/core/bad_client/tests/badreq.c | 15 +++++++++++++++ .../core/bad_client/tests/badreq_encoding.headers | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/core/bad_client/tests/badreq_encoding.headers diff --git a/test/core/bad_client/tests/badreq.c b/test/core/bad_client/tests/badreq.c index 3130a096540..bc6acd788f0 100644 --- a/test/core/bad_client/tests/badreq.c +++ b/test/core/bad_client/tests/badreq.c @@ -110,5 +110,20 @@ int main(int argc, char **argv) { "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", GRPC_BAD_CLIENT_DISCONNECT); + /* bad grpc-encoding algorithm */ + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR + "\x00\x00\xf5\x01\x04\x00\x00\x00\x01" + "\x10\x05:path\x08/foo/bar" + "\x10\x07:scheme\x04http" + "\x10\x07:method\x04POST" + "\x10\x0a:authority\x09localhost" + "\x10\x0c""content-type\x10""application/grpc" + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" + "\x10\x0dgrpc-encoding\x1cyou-dont-know-how-to-do-this" + "\x10\x02te\x08trailers" + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", + GRPC_BAD_CLIENT_DISCONNECT); + return 0; } diff --git a/test/core/bad_client/tests/badreq_encoding.headers b/test/core/bad_client/tests/badreq_encoding.headers new file mode 100644 index 00000000000..5639c1fd715 --- /dev/null +++ b/test/core/bad_client/tests/badreq_encoding.headers @@ -0,0 +1,12 @@ +# headers used in badreq.c +# use tools/codegen/core/gen_header_frame.py to generate the binary strings +# contained in the source code +:path: /foo/bar +:scheme: http +:method: POST +:authority: localhost +content-type: application/grpc +grpc-accept-encoding: identity,deflate,gzip +grpc-encoding: you-dont-know-how-to-do-this +te: trailers +user-agent: bad-client grpc-c/0.12.0.0 (linux)