OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // TODO(rtenhove) clean up frame buffer size calculations so that we aren't | 5 // TODO(rtenhove) clean up frame buffer size calculations so that we aren't |
6 // constantly adding and subtracting header sizes; this is ugly and error- | 6 // constantly adding and subtracting header sizes; this is ugly and error- |
7 // prone. | 7 // prone. |
8 | 8 |
9 #include "net/spdy/spdy_framer.h" | 9 #include "net/spdy/spdy_framer.h" |
10 | 10 |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 DLOG(INFO) << "NOOP control frame found. Ignoring."; | 416 DLOG(INFO) << "NOOP control frame found. Ignoring."; |
417 CHANGE_STATE(SPDY_AUTO_RESET); | 417 CHANGE_STATE(SPDY_AUTO_RESET); |
418 return; | 418 return; |
419 } | 419 } |
420 | 420 |
421 if (validate_control_frame_sizes_) { | 421 if (validate_control_frame_sizes_) { |
422 // Do some sanity checking on the control frame sizes. | 422 // Do some sanity checking on the control frame sizes. |
423 switch (current_control_frame.type()) { | 423 switch (current_control_frame.type()) { |
424 case SYN_STREAM: | 424 case SYN_STREAM: |
425 if (current_control_frame.length() < | 425 if (current_control_frame.length() < |
426 SpdySynStreamControlFrame::size() - SpdyControlFrame::size()) | 426 SpdySynStreamControlFrame::size() - SpdyControlFrame::kHeaderSize) |
427 set_error(SPDY_INVALID_CONTROL_FRAME); | 427 set_error(SPDY_INVALID_CONTROL_FRAME); |
428 break; | 428 break; |
429 case SYN_REPLY: | 429 case SYN_REPLY: |
430 if (current_control_frame.length() < | 430 if (current_control_frame.length() < |
431 SpdySynReplyControlFrame::size() - SpdyControlFrame::size()) | 431 SpdySynReplyControlFrame::size() - SpdyControlFrame::kHeaderSize) |
432 set_error(SPDY_INVALID_CONTROL_FRAME); | 432 set_error(SPDY_INVALID_CONTROL_FRAME); |
433 break; | 433 break; |
434 case RST_STREAM: | 434 case RST_STREAM: |
435 if (current_control_frame.length() != | 435 if (current_control_frame.length() != |
436 SpdyRstStreamControlFrame::size() - SpdyFrame::kHeaderSize) | 436 SpdyRstStreamControlFrame::size() - SpdyFrame::kHeaderSize) |
437 set_error(SPDY_INVALID_CONTROL_FRAME); | 437 set_error(SPDY_INVALID_CONTROL_FRAME); |
438 break; | 438 break; |
439 case SETTINGS: | 439 case SETTINGS: |
440 if (current_control_frame.length() < | 440 if (current_control_frame.length() < |
441 SpdySettingsControlFrame::size() - SpdyControlFrame::size()) | 441 SpdySettingsControlFrame::size() - SpdyControlFrame::kHeaderSize) |
442 set_error(SPDY_INVALID_CONTROL_FRAME); | 442 set_error(SPDY_INVALID_CONTROL_FRAME); |
443 break; | 443 break; |
444 case GOAWAY: | 444 case GOAWAY: |
445 if (current_control_frame.length() != | 445 if (current_control_frame.length() != |
446 SpdyGoAwayControlFrame::size() - SpdyFrame::kHeaderSize) | 446 SpdyGoAwayControlFrame::size() - SpdyFrame::kHeaderSize) |
447 set_error(SPDY_INVALID_CONTROL_FRAME); | 447 set_error(SPDY_INVALID_CONTROL_FRAME); |
448 break; | 448 break; |
449 case HEADERS: | 449 case HEADERS: |
450 if (current_control_frame.length() < | 450 if (current_control_frame.length() < |
451 SpdyHeadersControlFrame::size() - SpdyControlFrame::size()) | 451 SpdyHeadersControlFrame::size() - SpdyControlFrame::kHeaderSize) |
452 set_error(SPDY_INVALID_CONTROL_FRAME); | 452 set_error(SPDY_INVALID_CONTROL_FRAME); |
453 break; | 453 break; |
454 case WINDOW_UPDATE: | 454 case WINDOW_UPDATE: |
455 if (current_control_frame.length() != | 455 if (current_control_frame.length() != |
456 SpdyWindowUpdateControlFrame::size() - SpdyControlFrame::size()) | 456 SpdyWindowUpdateControlFrame::size() - |
| 457 SpdyControlFrame::kHeaderSize) |
457 set_error(SPDY_INVALID_CONTROL_FRAME); | 458 set_error(SPDY_INVALID_CONTROL_FRAME); |
458 break; | 459 break; |
459 case PING: | 460 case PING: |
460 if (current_control_frame.length() != | 461 if (current_control_frame.length() != |
461 SpdyPingControlFrame::size() - SpdyControlFrame::size()) | 462 SpdyPingControlFrame::size() - SpdyControlFrame::kHeaderSize) |
462 set_error(SPDY_INVALID_CONTROL_FRAME); | 463 set_error(SPDY_INVALID_CONTROL_FRAME); |
463 break; | 464 break; |
464 default: | 465 default: |
465 LOG(WARNING) << "Valid " << display_protocol_ | 466 LOG(WARNING) << "Valid " << display_protocol_ |
466 << " control frame with unhandled type: " | 467 << " control frame with unhandled type: " |
467 << current_control_frame.type(); | 468 << current_control_frame.type(); |
468 DCHECK(false); | 469 DCHECK(false); |
469 set_error(SPDY_INVALID_CONTROL_FRAME); | 470 set_error(SPDY_INVALID_CONTROL_FRAME); |
470 break; | 471 break; |
471 } | 472 } |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 | 1689 |
1689 void SpdyFramer::set_enable_compression_default(bool value) { | 1690 void SpdyFramer::set_enable_compression_default(bool value) { |
1690 compression_default_ = value; | 1691 compression_default_ = value; |
1691 } | 1692 } |
1692 | 1693 |
1693 void SpdyFramer::set_validate_control_frame_sizes(bool value) { | 1694 void SpdyFramer::set_validate_control_frame_sizes(bool value) { |
1694 validate_control_frame_sizes_ = value; | 1695 validate_control_frame_sizes_ = value; |
1695 } | 1696 } |
1696 | 1697 |
1697 } // namespace spdy | 1698 } // namespace spdy |
OLD | NEW |