Commit 5677e4d1 by Jamie Madill Committed by Commit Bot

Buffer11: Ensure we don't overflow on setData.

When mapping uniform buffers for very large buffers, we could end up copying past buffer bounds. This would trigger crashes on some configs. We can fix this by clamping the copy size correctly. BUG=chromium:659892 Change-Id: I9d1af984da34867692d4c7b8908c016ebec7a63b Reviewed-on: https://chromium-review.googlesource.com/404931Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 2bfc4119
...@@ -841,10 +841,14 @@ gl::Error Buffer11::BufferStorage::setData(const uint8_t *data, size_t offset, s ...@@ -841,10 +841,14 @@ gl::Error Buffer11::BufferStorage::setData(const uint8_t *data, size_t offset, s
{ {
ASSERT(isMappable(GL_MAP_WRITE_BIT)); ASSERT(isMappable(GL_MAP_WRITE_BIT));
// Uniform storage can have a different internal size than the buffer size. Ensure we don't
// overflow.
size_t mapSize = std::min(size, mBufferSize - offset);
uint8_t *writePointer = nullptr; uint8_t *writePointer = nullptr;
ANGLE_TRY(map(offset, size, GL_MAP_WRITE_BIT, &writePointer)); ANGLE_TRY(map(offset, mapSize, GL_MAP_WRITE_BIT, &writePointer));
memcpy(writePointer, data, size); memcpy(writePointer, data, mapSize);
unmap(); unmap();
......
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