RESTRICT AUTOMERGE: Fix heap buffer overflow

Bug: b/118143775
Bug: oss-fuzz:11040

Because we're sampling, the offset ends up the same as the width. Back
up to the left enough to fit the bytes we will write.

Include SafetyNet logging from
https://skia-review.googlesource.com/c/skia/+/171227
Note: SafetyNet logging code revised since the actual API is missing,
but it's functionally identical

Test: run cts -m CtsSecurityTestCases -t android.security.cts.BitmapFactorySecurityTests#test_android_bug_118143775

Change-Id: Ie476a0191b66c2322446b9c0922f630d6e971645
(cherry picked from commit 8adcfda1344480c277f8f3dc3e76ff4c119a80a7)
1 file changed