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

Unified Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 2310243002: Supress integer-overflow in TexSubImage2D(3D)Impl (Closed)
Patch Set: move check to call sites Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/client/gles2_implementation.cc
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index aa3b18d4e783c28b8bb69de4ca9198c64856346c..ee37d267a41fbdfe6ca5d83b77b9ca6bba8d6384 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -19,6 +19,7 @@
#include <string>
#include "base/atomic_sequence_num.h"
#include "base/compiler_specific.h"
+#include "base/numerics/safe_math.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/sys_info.h"
@@ -2875,6 +2876,12 @@ void GLES2Implementation::TexSubImage2D(
pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size;
ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_);
+ base::CheckedNumeric<GLint> checked_yoffset = yoffset;
Zhenyao Mo 2016/09/07 21:03:18 Let's do xoffset + width also.
xidachen 2016/09/07 23:05:19 Done.
+ checked_yoffset += height;
+ if (!checked_yoffset.IsValid()) {
+ SetGLError(GL_INVALID_VALUE, "TexSubImage2D", "yoffset + height overflows");
+ return;
+ }
TexSubImage2DImpl(
target, level, xoffset, yoffset, width, height, format, type,
unpadded_row_size, pixels, padded_row_size, GL_FALSE, &buffer,
@@ -3000,6 +3007,18 @@ void GLES2Implementation::TexSubImage3D(
pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size;
ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_);
+ base::CheckedNumeric<GLint> checked_yoffset = yoffset;
+ checked_yoffset += height;
+ if (!checked_yoffset.IsValid()) {
+ SetGLError(GL_INVALID_VALUE, "TexSubImage3D", "yoffset + height overflows");
+ return;
+ }
+ base::CheckedNumeric<GLint> checked_zoffset = zoffset;
+ checked_zoffset += depth;
+ if (!checked_zoffset.IsValid()) {
+ SetGLError(GL_INVALID_VALUE, "TexSubImage3D", "zoffset + depth overflows");
+ return;
+ }
TexSubImage3DImpl(
target, level, xoffset, yoffset, zoffset, width, height, depth,
format, type, unpadded_row_size, pixels, padded_row_size, GL_FALSE,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698