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

Unified Diff: webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc

Issue 1219703002: Prevent out-of-bounds reads for short FEC packets. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/fec_receiver_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
diff --git a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
index 9d9550b0b1bf966d667604df42866cb27af7760b..cfb9279c22051b25295be72ae04e3b5206770cac 100644
--- a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
@@ -81,6 +81,11 @@ int32_t FecReceiverImpl::AddReceivedRedPacket(
uint8_t REDHeaderLength = 1;
size_t payload_data_length = packet_length - header.headerLength;
+ if (payload_data_length == 0) {
+ LOG(LS_WARNING) << "Corrupt/truncated FEC packet.";
+ return -1;
+ }
+
// Add to list without RED header, aka a virtual RTP packet
// we remove the RED header
@@ -99,14 +104,18 @@ int32_t FecReceiverImpl::AddReceivedRedPacket(
if (incoming_rtp_packet[header.headerLength] & 0x80) {
// f bit set in RED header
REDHeaderLength = 4;
+ if (payload_data_length < REDHeaderLength) {
+ LOG(LS_WARNING) << "Corrupt/truncated FEC packet.";
+ delete received_packet;
+ return -1;
+ }
+
uint16_t timestamp_offset =
(incoming_rtp_packet[header.headerLength + 1]) << 8;
timestamp_offset +=
incoming_rtp_packet[header.headerLength + 2];
timestamp_offset = timestamp_offset >> 2;
if (timestamp_offset != 0) {
- // |timestampOffset| should be 0. However, it's possible this is the first
- // location a corrupt payload can be caught, so don't assert.
LOG(LS_WARNING) << "Corrupt payload found.";
delete received_packet;
return -1;
@@ -118,15 +127,13 @@ int32_t FecReceiverImpl::AddReceivedRedPacket(
// check next RED header
if (incoming_rtp_packet[header.headerLength + 4] & 0x80) {
- // more than 2 blocks in packet not supported
+ LOG(LS_WARNING) << "More than 2 blocks in packet not supported.";
delete received_packet;
- assert(false);
return -1;
}
if (blockLength > payload_data_length - REDHeaderLength) {
- // block length longer than packet
+ LOG(LS_WARNING) << "Block length longer than packet.";
delete received_packet;
- assert(false);
return -1;
}
}
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/fec_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698