Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 1 | # HG changeset patch |
| 2 | # User Sam Lantinga <slouken@libsdl.org> |
| 3 | # Date 1550504903 28800 |
| 4 | # Mon Feb 18 07:48:23 2019 -0800 |
| 5 | # Branch SDL-1.2 |
| 6 | # Node ID 19d8c3b9c25143f71a34ff40ce1df91b4b3e3b78 |
| 7 | # Parent 8586f153eedec4c4e07066d6248ebdf67f10a229 |
| 8 | Fixed bug 4500 - Heap-Buffer Overflow in Map1toN pertaining to SDL_pixels.c |
| 9 | |
| 10 | Petr Pisar |
| 11 | |
| 12 | The reproducer has these data in BITMAPINFOHEADER: |
| 13 | |
| 14 | biSize = 40 |
| 15 | biBitCount = 8 |
| 16 | biClrUsed = 131075 |
| 17 | |
| 18 | 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. |
| 19 | |
| 20 | CVE: CVE-2019-7638 |
| 21 | CVE: CVE-2019-7636 |
| 22 | Upstream-Status: Backport |
| 23 | Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> |
| 24 | |
| 25 | diff -r 8586f153eede -r 19d8c3b9c251 src/video/SDL_bmp.c |
| 26 | --- a/src/video/SDL_bmp.c Sun Jan 13 15:27:50 2019 +0100 |
| 27 | +++ b/src/video/SDL_bmp.c Mon Feb 18 07:48:23 2019 -0800 |
| 28 | @@ -233,6 +233,10 @@ |
| 29 | if ( palette ) { |
| 30 | if ( biClrUsed == 0 ) { |
| 31 | biClrUsed = 1 << biBitCount; |
| 32 | + } else if ( biClrUsed > (1 << biBitCount) ) { |
| 33 | + SDL_SetError("BMP file has an invalid number of colors"); |
| 34 | + was_error = SDL_TRUE; |
| 35 | + goto done; |
| 36 | } |
| 37 | if ( biSize == 12 ) { |
| 38 | for ( i = 0; i < (int)biClrUsed; ++i ) { |