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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_packet.cc

Issue 2327743003: Fix oversized rtp header extension parsing. (Closed)
Patch Set: Fix + nits nearby Created 4 years, 3 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 | webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.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 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/rtp_rtcp/source/rtp_packet.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtp_packet.h"
12 12
13 #include <cstring> 13 #include <cstring>
14 #include <utility>
14 15
15 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
16 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
17 #include "webrtc/base/random.h" 18 #include "webrtc/base/random.h"
18 #include "webrtc/common_types.h" 19 #include "webrtc/common_types.h"
19 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" 20 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" 21 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h"
21 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 22 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
22 23
23 namespace webrtc { 24 namespace webrtc {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 while (extensions_size_ + kOneByteHeaderSize < extensions_capacity) { 391 while (extensions_size_ + kOneByteHeaderSize < extensions_capacity) {
391 uint8_t id = buffer[extension_offset + extensions_size_] >> 4; 392 uint8_t id = buffer[extension_offset + extensions_size_] >> 4;
392 if (id == kReservedId) { 393 if (id == kReservedId) {
393 break; 394 break;
394 } else if (id == kPaddingId) { 395 } else if (id == kPaddingId) {
395 extensions_size_++; 396 extensions_size_++;
396 continue; 397 continue;
397 } 398 }
398 uint8_t length = 399 uint8_t length =
399 1 + (buffer[extension_offset + extensions_size_] & 0xf); 400 1 + (buffer[extension_offset + extensions_size_] & 0xf);
401 if (extensions_size_ + kOneByteHeaderSize + length >
402 extensions_capacity) {
403 LOG(LS_WARNING) << "Oversized rtp header extension.";
404 break;
405 }
406 if (num_extensions_ >= kMaxExtensionHeaders) {
407 LOG(LS_WARNING) << "Too many rtp header extensions.";
408 break;
409 }
400 extensions_size_ += kOneByteHeaderSize; 410 extensions_size_ += kOneByteHeaderSize;
401 if (num_extensions_ >= kMaxExtensionHeaders) {
402 LOG(LS_WARNING) << "Too many extensions.";
403 return false;
404 }
405 extension_entries_[num_extensions_].type = 411 extension_entries_[num_extensions_].type =
406 extensions_ ? extensions_->GetType(id) 412 extensions_ ? extensions_->GetType(id)
407 : ExtensionManager::kInvalidType; 413 : ExtensionManager::kInvalidType;
408 extension_entries_[num_extensions_].length = length; 414 extension_entries_[num_extensions_].length = length;
409 extension_entries_[num_extensions_].offset = 415 extension_entries_[num_extensions_].offset =
410 extension_offset + extensions_size_; 416 extension_offset + extensions_size_;
411 num_extensions_++; 417 num_extensions_++;
412 extensions_size_ += length; 418 extensions_size_ += length;
413 } 419 }
414 } 420 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 uint8_t* Packet::WriteAt(size_t offset) { 522 uint8_t* Packet::WriteAt(size_t offset) {
517 return buffer_.data() + offset; 523 return buffer_.data() + offset;
518 } 524 }
519 525
520 void Packet::WriteAt(size_t offset, uint8_t byte) { 526 void Packet::WriteAt(size_t offset, uint8_t byte) {
521 buffer_.data()[offset] = byte; 527 buffer_.data()[offset] = byte;
522 } 528 }
523 529
524 } // namespace rtp 530 } // namespace rtp
525 } // namespace webrtc 531 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698