Avoid OOB params access in call log wrapper
authorMika Väinölä <mika.vainola@siru.fi>
Thu, 4 Nov 2021 13:52:05 +0000 (15:52 +0200)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Sat, 13 Nov 2021 16:04:45 +0000 (16:04 +0000)
Some negative coverage tests call glTexParameter*v and
glGetSamplerParameter*v with GL_TEXTURE_BORDER_COLOR and a pointer to
a single GLint, GLuint or GLfloat. The call log wrapper functions
attempt to log all four parameters expected for the pname and we get
OOB access for params. Avoid this by using arrays of four instead of
single values for params.

Affects:
dEQP-GLES31.functional.debug.negative_coverage.*.texture.texparameter*
dEQP-GLES31.functional.debug.negative_coverage.*.shader.get_sampler_parameter*
dEQP-GLES31.functional.debug.error_filters.case_11
dEQP-GLES31.functional.debug.error_filters.case_18
dEQP-GLES31.functional.debug.error_filters.case_22
dEQP-GLES31.functional.debug.error_groups.case_11

Components: OpenGL

VK-GL-CTS issue: 3273

Change-Id: If244a008c9cfcc6cc443e8d5475f6ce4add1c838

modules/gles31/functional/es31fNegativeShaderApiTests.cpp
modules/gles31/functional/es31fNegativeTextureApiTests.cpp

index e82734a..effbf67 100644 (file)
@@ -656,18 +656,18 @@ void get_sampler_parameterIiv (NegativeTestContext& ctx)
        if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
                throw tcu::NotSupportedError("glGetSamplerParameterIiv is not supported.", DE_NULL, __FILE__, __LINE__);
 
-       GLuint  sampler         = 0x1234;
-       GLint   borderColor     = 0x1234;
+       GLuint  sampler                 = 0x1234;
+       GLint   borderColor[]   = { 0x1234, 0x4123, 0x3412, 0x2341 };
 
        ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
-       ctx.glGetSamplerParameterIiv(sampler, GL_TEXTURE_BORDER_COLOR, &borderColor);
+       ctx.glGetSamplerParameterIiv(sampler, GL_TEXTURE_BORDER_COLOR, &borderColor[0]);
        ctx.expectError(GL_INVALID_OPERATION);
        ctx.endSection();
 
        ctx.glGenSamplers(1, &sampler);
 
        ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
-       ctx.glGetSamplerParameterIiv(sampler, -1, &borderColor);
+       ctx.glGetSamplerParameterIiv(sampler, -1, &borderColor[0]);
        ctx.expectError(GL_INVALID_ENUM);
        ctx.endSection();
 
@@ -679,18 +679,18 @@ void get_sampler_parameterIuiv (NegativeTestContext& ctx)
        if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
                throw tcu::NotSupportedError("glGetSamplerParameterIuiv is not supported.", DE_NULL, __FILE__, __LINE__);
 
-       GLuint  sampler         = 0x1234;
-       GLuint  borderColor     = 0x1234;
+       GLuint  sampler                 = 0x1234;
+       GLuint  borderColor[]   = { 0x1234, 0x4123, 0x3412, 0x2341 };
 
        ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
-       ctx.glGetSamplerParameterIuiv(sampler, GL_TEXTURE_BORDER_COLOR, &borderColor);
+       ctx.glGetSamplerParameterIuiv(sampler, GL_TEXTURE_BORDER_COLOR, &borderColor[0]);
        ctx.expectError(GL_INVALID_OPERATION);
        ctx.endSection();
 
        ctx.glGenSamplers(1, &sampler);
 
        ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
-       ctx.glGetSamplerParameterIuiv(sampler, -1, &borderColor);
+       ctx.glGetSamplerParameterIuiv(sampler, -1, &borderColor[0]);
        ctx.expectError(GL_INVALID_ENUM);
        ctx.endSection();
 
index c2f9d47..b49a401 100644 (file)
@@ -1994,7 +1994,7 @@ void texparameterf (NegativeTestContext& ctx)
 
 void texparameteriv (NegativeTestContext& ctx)
 {
-       GLint params[1] = {GL_LINEAR};
+       GLint params[4] = { GL_LINEAR, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM };
 
        GLuint texture = 0x1234;
        ctx.glGenTextures(1, &texture);
@@ -2111,7 +2111,7 @@ void texparameteriv (NegativeTestContext& ctx)
 
 void texparameterfv (NegativeTestContext& ctx)
 {
-       GLfloat params[1] = {GL_LINEAR};
+       GLfloat params[4] = { GL_LINEAR, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM };
        GLuint texture = 0x1234;
        ctx.glGenTextures(1, &texture);
        ctx.glBindTexture(GL_TEXTURE_2D, texture);
@@ -2231,7 +2231,7 @@ void texparameterIiv (NegativeTestContext& ctx)
        if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
                throw tcu::NotSupportedError("glTexParameterIiv is not supported.", DE_NULL, __FILE__, __LINE__);
 
-       GLint textureMode[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX };
+       GLint textureMode[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_INVALID_ENUM, GL_INVALID_ENUM };
        ctx.beginSection("GL_INVALID_ENUM is generated if target is not a valid target.");
        ctx.glTexParameterIiv(0, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
        ctx.expectError(GL_INVALID_ENUM);
@@ -2341,7 +2341,7 @@ void texparameterIuiv (NegativeTestContext& ctx)
        if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
                throw tcu::NotSupportedError("glTexParameterIuiv is not supported.", DE_NULL, __FILE__, __LINE__);
 
-       GLuint textureMode[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX };
+       GLuint textureMode[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_INVALID_ENUM, GL_INVALID_ENUM };
        ctx.beginSection("GL_INVALID_ENUM is generated if target is not a valid target.");
        ctx.glTexParameterIuiv(0, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
        ctx.expectError(GL_INVALID_ENUM);