| # User Sam Lantinga <slouken@libsdl.org> |
| # Mon Feb 18 07:48:23 2019 -0800 |
| # Node ID 19d8c3b9c25143f71a34ff40ce1df91b4b3e3b78 |
| # Parent 8586f153eedec4c4e07066d6248ebdf67f10a229 |
| Fixed bug 4500 - Heap-Buffer Overflow in Map1toN pertaining to SDL_pixels.c |
| The reproducer has these data in BITMAPINFOHEADER: |
| SDL_LoadBMP_RW() function passes biBitCount as a color depth to SDL_CreateRGBSurface(), thus 256-color pallete is allocated. But then biClrUsed colors are read from a file and stored into the palette. SDL_LoadBMP_RW should report an error if biClrUsed is greater than 2^biBitCount. |
| Upstream-Status: Backport |
| Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> |
| diff -r 8586f153eede -r 19d8c3b9c251 src/video/SDL_bmp.c |
| --- a/src/video/SDL_bmp.c Sun Jan 13 15:27:50 2019 +0100 |
| +++ b/src/video/SDL_bmp.c Mon Feb 18 07:48:23 2019 -0800 |
| biClrUsed = 1 << biBitCount; |
| + } else if ( biClrUsed > (1 << biBitCount) ) { |
| + SDL_SetError("BMP file has an invalid number of colors"); |
| for ( i = 0; i < (int)biClrUsed; ++i ) { |