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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 2528243002: Fix silent truncations when extracting values from CheckedNumeric (Closed)
Patch Set: compile cleanup and 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 6335 matching lines...) Expand 10 before | Expand all | Expand 10 after
6346 } 6346 }
6347 total_size += len; 6347 total_size += len;
6348 total_size += 1; // NULL at the end of each char array. 6348 total_size += 1; // NULL at the end of each char array.
6349 if (!total_size.IsValid()) { 6349 if (!total_size.IsValid()) {
6350 SetGLError(GL_INVALID_VALUE, func_name, "overflow"); 6350 SetGLError(GL_INVALID_VALUE, func_name, "overflow");
6351 return false; 6351 return false;
6352 } 6352 }
6353 header[ii + 1] = len; 6353 header[ii + 1] = len;
6354 } 6354 }
6355 // Pack data into a bucket on the service. 6355 // Pack data into a bucket on the service.
6356 helper_->SetBucketSize(kResultBucketId, total_size.ValueOrDefault(0)); 6356 helper_->SetBucketSize(kResultBucketId,
6357 total_size.template ValueOrDefault<uint32_t>(0));
6357 size_t offset = 0; 6358 size_t offset = 0;
6358 for (GLsizei ii = 0; ii <= count; ++ii) { 6359 for (GLsizei ii = 0; ii <= count; ++ii) {
6359 const char* src = 6360 const char* src =
6360 (ii == 0) ? reinterpret_cast<const char*>(&header[0]) : str[ii - 1]; 6361 (ii == 0) ? reinterpret_cast<const char*>(&header[0]) : str[ii - 1];
6361 base::CheckedNumeric<size_t> checked_size = 6362 base::CheckedNumeric<size_t> checked_size =
6362 (ii == 0) ? header_size : static_cast<size_t>(header[ii]); 6363 (ii == 0) ? header_size : static_cast<size_t>(header[ii]);
6363 if (ii > 0) { 6364 if (ii > 0) {
6364 checked_size += 1; // NULL in the end. 6365 checked_size += 1; // NULL in the end.
6365 } 6366 }
6366 if (!checked_size.IsValid()) { 6367 if (!checked_size.IsValid()) {
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
7030 cached_extensions_.clear(); 7031 cached_extensions_.clear();
7031 } 7032 }
7032 7033
7033 // Include the auto-generated part of this file. We split this because it means 7034 // Include the auto-generated part of this file. We split this because it means
7034 // we can easily edit the non-auto generated parts right here in this file 7035 // we can easily edit the non-auto generated parts right here in this file
7035 // instead of having to edit some template or the code generator. 7036 // instead of having to edit some template or the code generator.
7036 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 7037 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
7037 7038
7038 } // namespace gles2 7039 } // namespace gles2
7039 } // namespace gpu 7040 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698