Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: net/spdy/spdy_framer.cc

Issue 2805066: SPDY: Handle incorrect number of headers when parsing frame headers. (Closed)
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/spdy_framer.h" 5 #include "net/spdy/spdy_framer.h"
6 6
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/stats_counters.h" 8 #include "base/stats_counters.h"
9 9
10 #include "net/spdy/spdy_frame_builder.h" 10 #include "net/spdy/spdy_frame_builder.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 header_data = syn_frame.header_block(); 463 header_data = syn_frame.header_block();
464 header_length = syn_frame.header_block_len(); 464 header_length = syn_frame.header_block_len();
465 } 465 }
466 break; 466 break;
467 } 467 }
468 468
469 SpdyFrameBuilder builder(header_data, header_length); 469 SpdyFrameBuilder builder(header_data, header_length);
470 void* iter = NULL; 470 void* iter = NULL;
471 uint16 num_headers; 471 uint16 num_headers;
472 if (builder.ReadUInt16(&iter, &num_headers)) { 472 if (builder.ReadUInt16(&iter, &num_headers)) {
473 for (int index = 0; index < num_headers; ++index) { 473 int index = 0;
474 for ( ; index < num_headers; ++index) {
474 std::string name; 475 std::string name;
475 std::string value; 476 std::string value;
476 if (!builder.ReadString(&iter, &name)) 477 if (!builder.ReadString(&iter, &name))
477 break; 478 break;
478 if (!builder.ReadString(&iter, &value)) 479 if (!builder.ReadString(&iter, &value))
479 break; 480 break;
480 if (!name.size() || !value.size()) 481 if (!name.size() || !value.size())
481 return false; 482 return false;
482 if (block->find(name) == block->end()) { 483 if (block->find(name) == block->end()) {
483 (*block)[name] = value; 484 (*block)[name] = value;
484 } else { 485 } else {
485 return false; 486 return false;
486 } 487 }
487 } 488 }
488 return true; 489 return index == num_headers &&
490 iter == header_data + header_length;
489 } 491 }
490 return false; 492 return false;
491 } 493 }
492 494
493 /* static */ 495 /* static */
494 bool SpdyFramer::ParseSettings(const SpdySettingsControlFrame* frame, 496 bool SpdyFramer::ParseSettings(const SpdySettingsControlFrame* frame,
495 SpdySettings* settings) { 497 SpdySettings* settings) {
496 DCHECK_EQ(frame->type(), SETTINGS); 498 DCHECK_EQ(frame->type(), SETTINGS);
497 DCHECK(settings); 499 DCHECK(settings);
498 500
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 void SpdyFramer::set_enable_compression(bool value) { 1079 void SpdyFramer::set_enable_compression(bool value) {
1078 enable_compression_ = value; 1080 enable_compression_ = value;
1079 } 1081 }
1080 1082
1081 void SpdyFramer::set_enable_compression_default(bool value) { 1083 void SpdyFramer::set_enable_compression_default(bool value) {
1082 compression_default_ = value; 1084 compression_default_ = value;
1083 } 1085 }
1084 1086
1085 } // namespace spdy 1087 } // namespace spdy
1086 1088
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698