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

Side by Side Diff: webrtc/modules/audio_processing/aec/aec_core.cc

Issue 2971313002: Add a check in the BlockBuffer of AEC2 to guard for buffer overflows. (Closed)
Patch Set: Move declaration of variable to point of first use. Created 3 years, 5 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/common_audio/ring_buffer.c ('k') | no next file » | 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void BlockBuffer::Insert(const float block[PART_LEN]) { 199 void BlockBuffer::Insert(const float block[PART_LEN]) {
200 WebRtc_WriteBuffer(buffer_, block, 1); 200 WebRtc_WriteBuffer(buffer_, block, 1);
201 } 201 }
202 202
203 void BlockBuffer::ExtractExtendedBlock(float extended_block[PART_LEN2]) { 203 void BlockBuffer::ExtractExtendedBlock(float extended_block[PART_LEN2]) {
204 float* block_ptr = NULL; 204 float* block_ptr = NULL;
205 RTC_DCHECK_LT(0, AvaliableSpace()); 205 RTC_DCHECK_LT(0, AvaliableSpace());
206 206
207 // Extract the previous block. 207 // Extract the previous block.
208 WebRtc_MoveReadPtr(buffer_, -1); 208 WebRtc_MoveReadPtr(buffer_, -1);
209 WebRtc_ReadBuffer(buffer_, reinterpret_cast<void**>(&block_ptr), 209 size_t read_elements = WebRtc_ReadBuffer(
210 &extended_block[0], 1); 210 buffer_, reinterpret_cast<void**>(&block_ptr), &extended_block[0], 1);
211 RTC_CHECK_EQ(read_elements, 1);
211 if (block_ptr != &extended_block[0]) { 212 if (block_ptr != &extended_block[0]) {
212 memcpy(&extended_block[0], block_ptr, PART_LEN * sizeof(float)); 213 memcpy(&extended_block[0], block_ptr, PART_LEN * sizeof(float));
213 } 214 }
214 215
215 // Extract the current block. 216 // Extract the current block.
216 WebRtc_ReadBuffer(buffer_, reinterpret_cast<void**>(&block_ptr), 217 read_elements =
217 &extended_block[PART_LEN], 1); 218 WebRtc_ReadBuffer(buffer_, reinterpret_cast<void**>(&block_ptr),
219 &extended_block[PART_LEN], 1);
220 RTC_CHECK_EQ(read_elements, 1);
218 if (block_ptr != &extended_block[PART_LEN]) { 221 if (block_ptr != &extended_block[PART_LEN]) {
219 memcpy(&extended_block[PART_LEN], block_ptr, PART_LEN * sizeof(float)); 222 memcpy(&extended_block[PART_LEN], block_ptr, PART_LEN * sizeof(float));
220 } 223 }
221 } 224 }
222 225
223 int BlockBuffer::AdjustSize(int buffer_size_decrease) { 226 int BlockBuffer::AdjustSize(int buffer_size_decrease) {
224 return WebRtc_MoveReadPtr(buffer_, buffer_size_decrease); 227 return WebRtc_MoveReadPtr(buffer_, buffer_size_decrease);
225 } 228 }
226 229
227 size_t BlockBuffer::Size() { 230 size_t BlockBuffer::Size() {
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 2041
2039 int WebRtcAec_system_delay(AecCore* self) { 2042 int WebRtcAec_system_delay(AecCore* self) {
2040 return self->system_delay; 2043 return self->system_delay;
2041 } 2044 }
2042 2045
2043 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { 2046 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) {
2044 RTC_DCHECK_GE(delay, 0); 2047 RTC_DCHECK_GE(delay, 0);
2045 self->system_delay = delay; 2048 self->system_delay = delay;
2046 } 2049 }
2047 } // namespace webrtc 2050 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_audio/ring_buffer.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698