diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-21 21:49:14 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-21 21:49:14 +0000 |
commit | a19cb733bc10273d8e31c6a3e71d4d8f0b6b60f2 (patch) | |
tree | 43fd56c2ee64a8d58276b9eb8cf26144a537c59d /third_party/zlib | |
parent | 7e1415bb88ea8bf7a624e364dbf169fb16fccd5b (diff) | |
download | chromium_src-a19cb733bc10273d8e31c6a3e71d4d8f0b6b60f2.zip chromium_src-a19cb733bc10273d8e31c6a3e71d4d8f0b6b60f2.tar.gz chromium_src-a19cb733bc10273d8e31c6a3e71d4d8f0b6b60f2.tar.bz2 |
net: separate SPDY cookie with "; " as the new RFC requires.
Previously, SPDY cookies would look like:
"FOO=BAR;BAR=BOO;WIBBLE=WOBBLE;"
With this patch they will look like:
"FOO=BAR; BAR=BOO; WIBBLE=WOBBLE"
This will hurt compression a little as cookies are only matched completely so:
Cookie: FOO=BAR
|-----|
won't match against the next Cookie header with an additional cookie:
Cookie: FOO=BAR; BAR=BOO
|------||------|
However, once the set of cookies is stable, it does fine.
BUG=151433
Review URL: https://chromiumcodereview.appspot.com/10957038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/zlib')
-rw-r--r-- | third_party/zlib/deflate.c | 15 | ||||
-rw-r--r-- | third_party/zlib/deflate.h | 2 | ||||
-rw-r--r-- | third_party/zlib/mixed-source.patch | 39 |
3 files changed, 33 insertions, 23 deletions
diff --git a/third_party/zlib/deflate.c b/third_party/zlib/deflate.c index 02d1516..8043e5b 100644 --- a/third_party/zlib/deflate.c +++ b/third_party/zlib/deflate.c @@ -1309,7 +1309,7 @@ local uInt cookie_match(s, start, len) unsigned i; IPos cookie_location; - if (len >= MAX_MATCH) + if (len >= MAX_MATCH || len == 0) return 0; for (i = 0; i < len; i++) @@ -1329,6 +1329,13 @@ local uInt cookie_match(s, start, len) return 0; } } + /* Check that we aren't matching a prefix of another cookie by ensuring + * that the final byte is either a semicolon (which cannot appear in a + * cookie value), or the match is followed by non-cookie data. */ + if (s->window[cookie_location+len-1] != ';' && + class_at(s, cookie_location+len) != 0) { + return 0; + } s->match_start = cookie_location; return len; } @@ -1862,10 +1869,8 @@ local block_state deflate_slow(s, flush, clas) /* We require that a Z_CLASS_COOKIE match be * preceded by either a semicolon (which cannot be * part of a cookie), or non-cookie data. This is - * to prevent - * a cookie from being a prefix of another. - * spdy_framer.cc ensures that cookies are always - * terminated by a semicolon. */ + * to prevent a cookie from being a suffix of + * another. */ (class_at(s, s->prev_match-1) == Z_CLASS_STANDARD || *(s->window + s->prev_match-1) == ';')))) { uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; diff --git a/third_party/zlib/deflate.h b/third_party/zlib/deflate.h index 83b4602..2fe6fd6 100644 --- a/third_party/zlib/deflate.h +++ b/third_party/zlib/deflate.h @@ -91,7 +91,7 @@ typedef unsigned IPos; * save space in the various tables. IPos is used only for parameter passing. */ -#define Z_COOKIE_HASH_SIZE 64 +#define Z_COOKIE_HASH_SIZE 256 #define Z_COOKIE_HASH_MASK (Z_COOKIE_HASH_SIZE-1) typedef struct internal_state { diff --git a/third_party/zlib/mixed-source.patch b/third_party/zlib/mixed-source.patch index bd55ef4..ed54802 100644 --- a/third_party/zlib/mixed-source.patch +++ b/third_party/zlib/mixed-source.patch @@ -1,5 +1,5 @@ diff --git a/third_party/zlib/deflate.c b/third_party/zlib/deflate.c -index 5c4022f..02d1516 100644 +index 5c4022f..88b2ec0 100644 --- a/third_party/zlib/deflate.c +++ b/third_party/zlib/deflate.c @@ -70,14 +70,15 @@ typedef enum { @@ -213,7 +213,7 @@ index 5c4022f..02d1516 100644 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); -@@ -1204,20 +1293,67 @@ local uInt longest_match(s, cur_match) +@@ -1204,20 +1293,74 @@ local uInt longest_match(s, cur_match) } #endif /* ASMV */ @@ -233,7 +233,7 @@ index 5c4022f..02d1516 100644 + unsigned i; + IPos cookie_location; + -+ if (len >= MAX_MATCH) ++ if (len >= MAX_MATCH || len == 0) + return 0; + + for (i = 0; i < len; i++) @@ -253,6 +253,13 @@ index 5c4022f..02d1516 100644 + return 0; + } + } ++ /* Check that we aren't matching a prefix of another cookie by ensuring ++ * that the final byte is either a semicolon (which cannot appear in a ++ * cookie value), or non-cookie data. */ ++ if (s->window[cookie_location+len-1] != ';' && ++ class_at(s, cookie_location+len) != 0) { ++ return 0; ++ } + s->match_start = cookie_location; + return len; + } @@ -282,7 +289,7 @@ index 5c4022f..02d1516 100644 /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. * It is easy to get rid of this optimization if necessary. */ -@@ -1360,6 +1496,21 @@ local void fill_window(s) +@@ -1360,6 +1503,21 @@ local void fill_window(s) */ } while (--n); #endif @@ -304,7 +311,7 @@ index 5c4022f..02d1516 100644 more += wsize; } if (s->strm->avail_in == 0) return; -@@ -1378,6 +1529,9 @@ local void fill_window(s) +@@ -1378,6 +1536,9 @@ local void fill_window(s) Assert(more >= 2, "more < 2"); n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); @@ -314,7 +321,7 @@ index 5c4022f..02d1516 100644 s->lookahead += n; /* Initialize the hash value now that we have some input: */ -@@ -1459,9 +1613,10 @@ local void fill_window(s) +@@ -1459,9 +1620,10 @@ local void fill_window(s) * NOTE: this function should be optimized to avoid extra copying from * window to pending_buf. */ @@ -326,7 +333,7 @@ index 5c4022f..02d1516 100644 { /* Stored blocks are limited to 0xffff bytes, pending_buf is limited * to pending_buf_size, and each stored block has a 5 byte header: -@@ -1517,13 +1672,19 @@ local block_state deflate_stored(s, flush) +@@ -1517,13 +1679,19 @@ local block_state deflate_stored(s, flush) * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ @@ -347,7 +354,7 @@ index 5c4022f..02d1516 100644 for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes -@@ -1554,7 +1715,7 @@ local block_state deflate_fast(s, flush) +@@ -1554,7 +1722,7 @@ local block_state deflate_fast(s, flush) * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ @@ -356,7 +363,7 @@ index 5c4022f..02d1516 100644 /* longest_match() sets match_start */ } if (s->match_length >= MIN_MATCH) { -@@ -1613,12 +1774,25 @@ local block_state deflate_fast(s, flush) +@@ -1613,12 +1781,25 @@ local block_state deflate_fast(s, flush) * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ @@ -383,7 +390,7 @@ index 5c4022f..02d1516 100644 /* Process the input block. */ for (;;) { -@@ -1648,13 +1822,18 @@ local block_state deflate_slow(s, flush) +@@ -1648,13 +1829,18 @@ local block_state deflate_slow(s, flush) s->prev_length = s->match_length, s->prev_match = s->match_start; s->match_length = MIN_MATCH-1; @@ -405,7 +412,7 @@ index 5c4022f..02d1516 100644 /* longest_match() sets match_start */ if (s->match_length <= 5 && (s->strategy == Z_FILTERED -@@ -1673,7 +1852,22 @@ local block_state deflate_slow(s, flush) +@@ -1673,7 +1859,20 @@ local block_state deflate_slow(s, flush) /* If there was a match at the previous step and the current * match is not better, output the previous match: */ @@ -420,24 +427,22 @@ index 5c4022f..02d1516 100644 + /* We require that a Z_CLASS_COOKIE match be + * preceded by either a semicolon (which cannot be + * part of a cookie), or non-cookie data. This is -+ * to prevent -+ * a cookie from being a prefix of another. -+ * spdy_framer.cc ensures that cookies are always -+ * terminated by a semicolon. */ ++ * to prevent a cookie from being a suffix of ++ * another. */ + (class_at(s, s->prev_match-1) == Z_CLASS_STANDARD || + *(s->window + s->prev_match-1) == ';')))) { uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; /* Do not insert strings in hash table beyond this. */ diff --git a/third_party/zlib/deflate.h b/third_party/zlib/deflate.h -index cbf0d1e..83b4602 100644 +index cbf0d1e..2fe6fd6 100644 --- a/third_party/zlib/deflate.h +++ b/third_party/zlib/deflate.h @@ -91,6 +91,9 @@ typedef unsigned IPos; * save space in the various tables. IPos is used only for parameter passing. */ -+#define Z_COOKIE_HASH_SIZE 64 ++#define Z_COOKIE_HASH_SIZE 256 +#define Z_COOKIE_HASH_MASK (Z_COOKIE_HASH_SIZE-1) + typedef struct internal_state { |