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

Unified Diff: content/browser/renderer_host/media/audio_renderer_host.cc

Issue 11647012: Improve validation when creating audio streams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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
Index: content/browser/renderer_host/media/audio_renderer_host.cc
===================================================================
--- content/browser/renderer_host/media/audio_renderer_host.cc (revision 173637)
+++ content/browser/renderer_host/media/audio_renderer_host.cc (working copy)
@@ -219,27 +219,23 @@
void AudioRendererHost::OnCreateStream(
int stream_id, const media::AudioParameters& params, int input_channels) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- DCHECK(LookupById(stream_id) == NULL);
+ // media::AudioParameters is validated in the deserializer.
+ if (input_channels < 0 ||
+ input_channels > media::limits::kMaxChannels ||
+ LookupById(stream_id) != NULL) {
+ SendErrorMessage(stream_id);
+ return;
+ }
media::AudioParameters audio_params(params);
- uint32 buffer_size = media::AudioBus::CalculateMemorySize(audio_params);
- DCHECK_GT(buffer_size, 0U);
- DCHECK_LE(buffer_size,
- static_cast<uint32>(media::limits::kMaxPacketSizeInBytes));
- DCHECK_GE(input_channels, 0);
- DCHECK_LT(input_channels, media::limits::kMaxChannels);
-
// Calculate output and input memory size.
int output_memory_size = AudioBus::CalculateMemorySize(audio_params);
- DCHECK_GT(output_memory_size, 0);
int frames = audio_params.frames_per_buffer();
int input_memory_size =
AudioBus::CalculateMemorySize(input_channels, frames);
- DCHECK_GE(input_memory_size, 0);
-
scoped_ptr<AudioEntry> entry(new AudioEntry());
// Create the shared memory and share with the renderer process.
« no previous file with comments | « content/browser/renderer_host/media/audio_input_renderer_host.cc ('k') | content/common/media/audio_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698