summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-30 14:05:45 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-30 14:05:45 +0000
commitd92a81f8797e70bdb2dbed31c37fb23891d5acac (patch)
tree7863348dc4e6317d399953aa9e3ed2f695e62544 /net
parenta651a3894ea39c788ac42e337b4abb5dd155e0fb (diff)
downloadchromium_src-d92a81f8797e70bdb2dbed31c37fb23891d5acac.zip
chromium_src-d92a81f8797e70bdb2dbed31c37fb23891d5acac.tar.gz
chromium_src-d92a81f8797e70bdb2dbed31c37fb23891d5acac.tar.bz2
Handle the zero-length name or value case when parsing frame headers.
BUG=47482 TEST=net_unittests Contributed by: agayev@google.com Review URL: http://codereview.chromium.org/2884003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/spdy/spdy_framer.cc2
-rw-r--r--net/spdy/spdy_framer_test.cc28
2 files changed, 30 insertions, 0 deletions
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index 83652d3..9aea310 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -477,6 +477,8 @@ bool SpdyFramer::ParseHeaderBlock(const SpdyFrame* frame,
break;
if (!builder.ReadString(&iter, &value))
break;
+ if (!name.size() || !value.size())
+ return false;
if (block->find(name) == block->end()) {
(*block)[name] = value;
} else {
diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc
index 783c4ac..6192b40 100644
--- a/net/spdy/spdy_framer_test.cc
+++ b/net/spdy/spdy_framer_test.cc
@@ -234,6 +234,34 @@ TEST_F(SpdyFramerTest, MultiValueHeader) {
EXPECT_EQ(value, new_headers.find("name")->second);
}
+TEST_F(SpdyFramerTest, ZeroLengthHeader) {
+ SpdyHeaderBlock header1;
+ SpdyHeaderBlock header2;
+ SpdyHeaderBlock header3;
+
+ header1[""] = "value2";
+ header2["name3"] = "";
+ header3[""] = "";
+
+ SpdyFramer framer;
+ SpdyHeaderBlock parsed_headers;
+
+ scoped_ptr<SpdySynStreamControlFrame> frame1(
+ framer.CreateSynStream(1, 0, 1, CONTROL_FLAG_NONE, true, &header1));
+ EXPECT_TRUE(frame1.get() != NULL);
+ EXPECT_FALSE(framer.ParseHeaderBlock(frame1.get(), &parsed_headers));
+
+ scoped_ptr<SpdySynStreamControlFrame> frame2(
+ framer.CreateSynStream(1, 0, 1, CONTROL_FLAG_NONE, true, &header2));
+ EXPECT_TRUE(frame2.get() != NULL);
+ EXPECT_FALSE(framer.ParseHeaderBlock(frame2.get(), &parsed_headers));
+
+ scoped_ptr<SpdySynStreamControlFrame> frame3(
+ framer.CreateSynStream(1, 0, 1, CONTROL_FLAG_NONE, true, &header3));
+ EXPECT_TRUE(frame3.get() != NULL);
+ EXPECT_FALSE(framer.ParseHeaderBlock(frame3.get(), &parsed_headers));
+}
+
TEST_F(SpdyFramerTest, BasicCompression) {
SpdyHeaderBlock headers;
headers["server"] = "SpdyServer 1.0";