gifdec,Remap: avoid out of bounds colormap read

sanitize the requested length to be read against the reported size of
the table

BUG=webp:316

Change-Id: I1c471e93ab696a9d21a0142cf1987ffcf8f55dd2
This commit is contained in:
James Zern 2016-10-31 12:56:04 -07:00
parent 31b1e34342
commit f048d38d38

View File

@ -87,7 +87,8 @@ static void Remap(const GifFileType* const gif, const uint8_t* const src,
const GifColorType* colors;
const ColorMapObject* const cmap =
gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap;
if (cmap == NULL) return;
if (cmap == NULL || cmap->Colors == NULL) return;
if (len > cmap->ColorCount) len = cmap->ColorCount;
colors = cmap->Colors;
for (i = 0; i < len; ++i) {