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

Side by Side Diff: content/renderer/pepper/pepper_media_stream_track_host_base.cc

Issue 2528243002: Fix silent truncations when extracting values from CheckedNumeric (Closed)
Patch Set: compile fix Created 4 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 unified diff | Download patch
« no previous file with comments | « content/renderer/pepper/pepper_audio_encoder_host.cc ('k') | device/hid/hid_connection_mac.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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h" 5 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_math.h" 10 #include "base/numerics/safe_math.h"
(...skipping 29 matching lines...) Expand all
40 DCHECK_GT(buffer_size, 40 DCHECK_GT(buffer_size,
41 static_cast<int32_t>(sizeof(ppapi::MediaStreamBuffer::Header))); 41 static_cast<int32_t>(sizeof(ppapi::MediaStreamBuffer::Header)));
42 // Make each buffer 4 byte aligned. 42 // Make each buffer 4 byte aligned.
43 base::CheckedNumeric<int32_t> buffer_size_aligned = buffer_size; 43 base::CheckedNumeric<int32_t> buffer_size_aligned = buffer_size;
44 // TODO(amistry): "buffer size" might not == "buffer stride", in the same way 44 // TODO(amistry): "buffer size" might not == "buffer stride", in the same way
45 // that width != stride in an image buffer. 45 // that width != stride in an image buffer.
46 buffer_size_aligned += (4 - buffer_size % 4); 46 buffer_size_aligned += (4 - buffer_size % 4);
47 47
48 // TODO(penghuang): |HostAllocateSharedMemoryBuffer| uses sync IPC. We should 48 // TODO(penghuang): |HostAllocateSharedMemoryBuffer| uses sync IPC. We should
49 // avoid it. 49 // avoid it.
50 base::CheckedNumeric<int32_t> size = number_of_buffers * buffer_size_aligned; 50 base::CheckedNumeric<uint32_t> size = number_of_buffers * buffer_size_aligned;
51 if (!size.IsValid()) 51 if (!size.IsValid())
52 return false; 52 return false;
53 53
54 content::RenderThread* render_thread = content::RenderThread::Get(); 54 content::RenderThread* render_thread = content::RenderThread::Get();
55 std::unique_ptr<base::SharedMemory> shm( 55 std::unique_ptr<base::SharedMemory> shm(
56 render_thread->HostAllocateSharedMemoryBuffer(size.ValueOrDie())); 56 render_thread->HostAllocateSharedMemoryBuffer(size.ValueOrDie()));
57 if (!shm) 57 if (!shm)
58 return false; 58 return false;
59 59
60 base::SharedMemoryHandle shm_handle = shm->handle(); 60 base::SharedMemoryHandle shm_handle = shm->handle();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return PP_OK; 111 return PP_OK;
112 } 112 }
113 113
114 int32_t PepperMediaStreamTrackHostBase::OnHostMsgClose( 114 int32_t PepperMediaStreamTrackHostBase::OnHostMsgClose(
115 HostMessageContext* context) { 115 HostMessageContext* context) {
116 OnClose(); 116 OnClose();
117 return PP_OK; 117 return PP_OK;
118 } 118 }
119 119
120 } // namespace content 120 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_audio_encoder_host.cc ('k') | device/hid/hid_connection_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698