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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc

Issue 8345003: Make OpenGL string entry points validate the string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 16c7d85e338cae36e930b747b64be388643810e9..b6bd64bc96493807e30705a1e0be2ecc2584f1b6 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -1151,7 +1151,9 @@ TEST_F(GLES2DecoderTest, ShaderSourceAndGetShaderSourceValidArgs) {
TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) {
const char kSource[] = "hello";
+ const char kBadSource[] = "hello\a";
const uint32 kSourceSize = sizeof(kSource) - 1;
+ const uint32 kBadSourceSize = sizeof(kBadSource) - 1;
memcpy(shared_memory_address_, kSource, kSourceSize);
ShaderSource cmd;
cmd.Init(kInvalidClientId,
@@ -1173,6 +1175,11 @@ TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) {
cmd.Init(client_shader_id_,
kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize);
EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ memcpy(shared_memory_address_, kBadSource, kBadSourceSize);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kSharedMemoryOffset, kBadSourceSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
}
TEST_F(GLES2DecoderTest, ShaderSourceImmediateAndGetShaderSourceValidArgs) {
@@ -1924,8 +1931,11 @@ TEST_F(GLES2DecoderTest, BindAttribLocation) {
TEST_F(GLES2DecoderTest, BindAttribLocationInvalidArgs) {
const GLint kLocation = 2;
const char* kName = "testing";
+ const char* kBadName = "test\aing";
const uint32 kNameSize = strlen(kName);
+ const uint32 kBadNameSize = strlen(kBadName);
EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0);
+ memcpy(shared_memory_address_, kName, kNameSize);
BindAttribLocation cmd;
cmd.Init(kInvalidClientId, kLocation,
kSharedMemoryId, kSharedMemoryOffset, kNameSize);
@@ -1940,6 +1950,11 @@ TEST_F(GLES2DecoderTest, BindAttribLocationInvalidArgs) {
cmd.Init(client_program_id_, kLocation,
kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize);
EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ memcpy(shared_memory_address_, kBadName, kBadNameSize);
+ cmd.Init(client_program_id_, kLocation,
+ kSharedMemoryId, kSharedMemoryOffset, kBadNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
}
TEST_F(GLES2DecoderTest, BindAttribLocationImmediate) {
@@ -2029,6 +2044,8 @@ TEST_F(GLES2DecoderWithShaderTest, GetAttribLocation) {
TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationInvalidArgs) {
const uint32 kNameSize = strlen(kAttrib2Name);
+ const char* kBadName = "foo\abar";
+ const uint32 kBadNameSize = strlen(kBadName);
typedef GetAttribLocation::Result Result;
Result* result = GetSharedMemoryAs<Result*>();
*result = -1;
@@ -2074,6 +2091,13 @@ TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationInvalidArgs) {
kSharedBufferSize);
EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(-1, *result);
+ memcpy(name, kBadName, kBadNameSize);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kBadNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
}
TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationImmediate) {
@@ -2196,6 +2220,8 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformLocation) {
TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationInvalidArgs) {
const uint32 kNameSize = strlen(kUniform2Name);
+ const char* kBadName = "foo\abar";
+ const uint32 kBadNameSize = strlen(kBadName);
typedef GetUniformLocation::Result Result;
Result* result = GetSharedMemoryAs<Result*>();
*result = -1;
@@ -2241,6 +2267,13 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationInvalidArgs) {
kSharedBufferSize);
EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(-1, *result);
+ memcpy(name, kBadName, kBadNameSize);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kBadNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
}
TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationImmediate) {
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698