Metal: upstream "UBO convert only whole block". Authored by Dan Glastonbury; reviewed by Dean Jackson. This upstreams https://commits.webkit.org/264375@main . OpenGL doesn't guarantee that the buffer backing uniform blocks needs to be a multiple of the block size. When converting OpenGL layout blocks to Metal layout, ConvertUniformBufferData is rounding up the size of the backing buffer to a multiple of the block size which leads to reading out of bounds. To ensure we don't read outside the source buffer, this change replaces calls to `memcpy` with `memcpy_guarded` which accepts a pointer to the limit of available data and copies as much data as is available, writing zeroes for any unavailable amount. Conversion of bools didn't use memcpy, so the raw pointer is checked against maxSrcPtr and only dereferenced if valid, otherwise zero is used. This has been tested with ASan and UBSan enabled against the OpenGL dEQP tests for Uniform Buffer Objects in ANGLE. Fixed: angleproject:8292 Change-Id: I0d472277889f073e54a9049f01bc04f6965a7b68 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4754175 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Auto-Submit: Kenneth Russell <kbr@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>