32764144 Security Vulnerability - heap buffer overflow in libgiftranscode.so in colorMap->Colors[colorIndex] am: 6f763fef7a am: 9f00add2fb am: 71d4913462 am: 82fa311e9a am: cc649e4e1e am: 657379f51c
am: fb324f89bf
Change-Id: I8e57243cac35d74a28e5af1fd23800d5cb7cb080
diff --git a/jni/GifTranscoder.cpp b/jni/GifTranscoder.cpp
index 6245538..112feca 100644
--- a/jni/GifTranscoder.cpp
+++ b/jni/GifTranscoder.cpp
@@ -384,6 +384,11 @@
for (int y = 0; y < gifIn->Image.Height; y++) {
for (int x = 0; x < gifIn->Image.Width; x++) {
GifByteType colorIndex = *getPixel(rasterBits, gifIn->Image.Width, x, y);
+ if (colorIndex >= colorMap->ColorCount) {
+ LOGE("Color Index %d is out of bounds (count=%d)", colorIndex,
+ colorMap->ColorCount);
+ return false;
+ }
// This image may be smaller than the GIF's "logical screen"
int renderX = x + gifIn->Image.Left;