--- a/lib/dgif_lib.c 2016-04-02 23:34:00.000000000 +0800 +++ b/lib/dgif_lib_1.c 2019-07-17 11:42:30.488000000 +0800 @@ -288,7 +288,11 @@ DGifGetScreenDesc(GifFileType *GifFile) } else { GifFile->SColorMap = NULL; } - + /* + * No check here for whether the background color is in range for the + * screen color map. Possibly there should be. + */ + return GIF_OK; } --- a/util/gif2rgb.c 2016-03-18 00:24:17.000000000 +0800 +++ b/util/gif2rgb_1.c 2019-07-17 11:45:22.044000000 +0800 @@ -15,7 +15,7 @@ Toshio Kuratomi had written this in a co I (ESR) took this off the main to-do list in 2012 because I don't think the GIFLIB project actually needs to be in the converters-and-tools business. -Plenty of hackers do that; our jub is to supply stable library capability +Plenty of hackers do that; our job is to supply stable library capability with our utilities mainly interesting as test tools. ***************************************************************************/ @@ -461,7 +461,7 @@ static void GIF2RGB(int NumFiles, char * break; } } while (RecordType != TERMINATE_RECORD_TYPE); - + /* Lets dump it - set the global variables required and do it: */ ColorMap = (GifFile->Image.ColorMap ? GifFile->Image.ColorMap @@ -471,6 +471,12 @@ static void GIF2RGB(int NumFiles, char * exit(EXIT_FAILURE); } + /* check that the background color isn't garbage (SF bug #87) */ + if (GifFile->SBackGroundColor < 0 || GifFile->SBackGroundColor >= ColorMap->ColorCount) { + fprintf(stderr, "Background color out of range for colormap\n"); + exit(EXIT_FAILURE); + } + DumpScreen2RGB(OutFileName, OneFileFlag, ColorMap, ScreenBuffer,