Commit a7d8ada2 by James Dong Committed by Commit Bot

Test out-of-bounds writes in glCopyTexSubImage2D

Adds a test for out-of-bounds writes resulting from clipping the copy area to the size of the source framebuffer causing the destination area to be out of bounds. This causes a GL_INVALID_VALUE error according to the spec. Bug: angleproject:3355 Change-Id: I39638daa9b0c03cc82a6dbf6cabd0027e32a8ea8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1682111Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 77c8496b
...@@ -368,12 +368,6 @@ angle::Result TextureVk::copySubImageImpl(const gl::Context *context, ...@@ -368,12 +368,6 @@ angle::Result TextureVk::copySubImageImpl(const gl::Context *context,
// If negative offsets are given, clippedSourceArea ensures we don't read from those offsets. // If negative offsets are given, clippedSourceArea ensures we don't read from those offsets.
// However, that changes the sourceOffset->destOffset mapping. Here, destOffset is shifted by // However, that changes the sourceOffset->destOffset mapping. Here, destOffset is shifted by
// the same amount as clipped to correct the error. // the same amount as clipped to correct the error.
//
// TODO(syoussefi): a bug here is that we need to clip the extents to make sure the copy
// region does not overflow the image size. For example, if an FBO of size 16x16 is used as
// source and glCopyTexImage2D(..., -8, -8, 16, 16, ...) is used, then we will be copying to
// the region expanding from (8, 8) through (23, 23), while the image is only 16x16.
// http://anglebug.com/3355
const gl::Offset modifiedDestOffset(destOffset.x + clippedSourceArea.x - sourceArea.x, const gl::Offset modifiedDestOffset(destOffset.x + clippedSourceArea.x - sourceArea.x,
destOffset.y + clippedSourceArea.y - sourceArea.y, 0); destOffset.y + clippedSourceArea.y - sourceArea.y, 0);
......
...@@ -162,6 +162,10 @@ class CopyTexImageTest : public ANGLETest ...@@ -162,6 +162,10 @@ class CopyTexImageTest : public ANGLETest
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 0, 0, kFboSizes[0], kFboSizes[0]); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 0, 0, kFboSizes[0], kFboSizes[0]);
ASSERT_GL_ERROR(GL_INVALID_VALUE); ASSERT_GL_ERROR(GL_INVALID_VALUE);
// xoffset + width > w and yoffset + height > h, out of bounds
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, -1, 1 + kFboSizes[0], 1 + kFboSizes[0]);
ASSERT_GL_ERROR(GL_INVALID_VALUE);
// Copy the second fbo over a portion of the image. // Copy the second fbo over a portion of the image.
GLint offset = kFboSizes[0] / 2; GLint offset = kFboSizes[0] / 2;
GLint extent = kFboSizes[0] - offset; GLint extent = kFboSizes[0] - offset;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment