William A. Kennington III | b95905d | 2021-06-02 12:40:56 -0700 | [diff] [blame] | 1 | From 97fefd050976bbbfca9608499f6a7d9fb86e70db Mon Sep 17 00:00:00 2001 |
| 2 | From: Sam Lantinga <slouken@libsdl.org> |
| 3 | Date: Tue, 30 Jul 2019 11:00:00 -0700 |
| 4 | Subject: [PATCH] Fixed bug 4538 - validate image size when loading BMP files |
| 5 | --- |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 6 | Upstream-Status: Pending |
| 7 | |
William A. Kennington III | b95905d | 2021-06-02 12:40:56 -0700 | [diff] [blame] | 8 | src/video/SDL_bmp.c | 5 +++++ |
| 9 | 1 file changed, 5 insertions(+) |
| 10 | |
| 11 | diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c |
| 12 | index 8eadc5f..5b5e12c 100644 |
| 13 | --- a/src/video/SDL_bmp.c |
| 14 | +++ b/src/video/SDL_bmp.c |
| 15 | @@ -143,6 +143,11 @@ SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc) |
| 16 | (void) biYPelsPerMeter; |
| 17 | (void) biClrImportant; |
| 18 | |
| 19 | + if (biWidth <= 0 || biHeight == 0) { |
| 20 | + SDL_SetError("BMP file with bad dimensions (%dx%d)", biWidth, biHeight); |
| 21 | + was_error = SDL_TRUE; |
| 22 | + goto done; |
| 23 | + } |
| 24 | if (biHeight < 0) { |
| 25 | topDown = SDL_TRUE; |
| 26 | biHeight = -biHeight; |
| 27 | -- |
| 28 | 2.25.1 |
| 29 | |