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

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

Issue 2067793003: Fix crash parsing malformed rtp packet (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 payload_size_ = size - payload_offset_ - padding_size_; 409 payload_size_ = size - payload_offset_ - padding_size_;
410 return true; 410 return true;
411 } 411 }
412 412
413 bool Packet::FindExtension(ExtensionType type, 413 bool Packet::FindExtension(ExtensionType type,
414 uint8_t length, 414 uint8_t length,
415 uint16_t* offset) const { 415 uint16_t* offset) const {
416 RTC_DCHECK(offset); 416 RTC_DCHECK(offset);
417 for (size_t i = 0; i < num_extensions_; ++i) { 417 for (size_t i = 0; i < num_extensions_; ++i) {
418 if (extension_entries_[i].type == type) { 418 if (extension_entries_[i].type == type) {
419 RTC_CHECK_EQ(length, extension_entries_[i].length) 419 if (length != extension_entries_[i].length) {
420 << "Length mismatch for extension '" << type << "'" 420 LOG(LS_WARNING) << "Length mismatch for extension '" << type
421 << "should be " << length << ", received " 421 << "': expected " << static_cast<int>(length)
422 << extension_entries_[i].length; 422 << ", received "
423 << static_cast<int>(extension_entries_[i].length);
424 return false;
425 }
423 *offset = extension_entries_[i].offset; 426 *offset = extension_entries_[i].offset;
424 return true; 427 return true;
425 } 428 }
426 } 429 }
427 return false; 430 return false;
428 } 431 }
429 432
430 bool Packet::AllocateExtension(ExtensionType type, 433 bool Packet::AllocateExtension(ExtensionType type,
431 uint8_t length, 434 uint8_t length,
432 uint16_t* offset) { 435 uint16_t* offset) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 uint8_t* Packet::WriteAt(size_t offset) { 503 uint8_t* Packet::WriteAt(size_t offset) {
501 return buffer_.data() + offset; 504 return buffer_.data() + offset;
502 } 505 }
503 506
504 void Packet::WriteAt(size_t offset, uint8_t byte) { 507 void Packet::WriteAt(size_t offset, uint8_t byte) {
505 buffer_.data()[offset] = byte; 508 buffer_.data()[offset] = byte;
506 } 509 }
507 510
508 } // namespace rtp 511 } // namespace rtp
509 } // namespace webrtc 512 } // 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