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

Side by Side Diff: webrtc/modules/video_coding/main/source/session_info.cc

Issue 1238033003: Prevent OOB reads for truncated H264 STAP-A packets. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: added logging + todos Created 5 years, 4 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 | « webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc ('k') | webrtc/test/call_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 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 for (it = packets_.begin(); it != packet_it; ++it) 126 for (it = packets_.begin(); it != packet_it; ++it)
127 offset += (*it).sizeBytes; 127 offset += (*it).sizeBytes;
128 128
129 // Set the data pointer to pointing to the start of this packet in the 129 // Set the data pointer to pointing to the start of this packet in the
130 // frame buffer. 130 // frame buffer.
131 const uint8_t* packet_buffer = packet.dataPtr; 131 const uint8_t* packet_buffer = packet.dataPtr;
132 packet.dataPtr = frame_buffer + offset; 132 packet.dataPtr = frame_buffer + offset;
133 133
134 // We handle H.264 STAP-A packets in a special way as we need to remove the 134 // We handle H.264 STAP-A packets in a special way as we need to remove the
135 // two length bytes between each NAL unit, and potentially add start codes. 135 // two length bytes between each NAL unit, and potentially add start codes.
136 // TODO(pbos): Remove H264 parsing from this step and use a fragmentation
137 // header supplied by the H264 depacketizer.
136 const size_t kH264NALHeaderLengthInBytes = 1; 138 const size_t kH264NALHeaderLengthInBytes = 1;
137 const size_t kLengthFieldLength = 2; 139 const size_t kLengthFieldLength = 2;
138 if (packet.codecSpecificHeader.codec == kRtpVideoH264 && 140 if (packet.codecSpecificHeader.codec == kRtpVideoH264 &&
139 packet.codecSpecificHeader.codecHeader.H264.packetization_type == 141 packet.codecSpecificHeader.codecHeader.H264.packetization_type ==
140 kH264StapA) { 142 kH264StapA) {
141 size_t required_length = 0; 143 size_t required_length = 0;
142 const uint8_t* nalu_ptr = packet_buffer + kH264NALHeaderLengthInBytes; 144 const uint8_t* nalu_ptr = packet_buffer + kH264NALHeaderLengthInBytes;
143 while (nalu_ptr < packet_buffer + packet.sizeBytes) { 145 while (nalu_ptr < packet_buffer + packet.sizeBytes) {
144 size_t length = BufferToUWord16(nalu_ptr); 146 size_t length = BufferToUWord16(nalu_ptr);
145 required_length += 147 required_length +=
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 if (empty_seq_num_high_ == -1) 532 if (empty_seq_num_high_ == -1)
531 empty_seq_num_high_ = seq_num; 533 empty_seq_num_high_ = seq_num;
532 else 534 else
533 empty_seq_num_high_ = LatestSequenceNumber(seq_num, empty_seq_num_high_); 535 empty_seq_num_high_ = LatestSequenceNumber(seq_num, empty_seq_num_high_);
534 if (empty_seq_num_low_ == -1 || IsNewerSequenceNumber(empty_seq_num_low_, 536 if (empty_seq_num_low_ == -1 || IsNewerSequenceNumber(empty_seq_num_low_,
535 seq_num)) 537 seq_num))
536 empty_seq_num_low_ = seq_num; 538 empty_seq_num_low_ = seq_num;
537 } 539 }
538 540
539 } // namespace webrtc 541 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc ('k') | webrtc/test/call_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698