aboutsummaryrefslogtreecommitdiffstats
path: root/main/sdl2_image/CVE-2017-14441.patch
blob: 19c30bbf99511518b1011e136789440249fa132d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# HG changeset patch
# User Ryan C. Gordon <icculus@icculus.org>
# Date 1516816924 18000
# Node ID a1e9b624ca1033f893e93691802682bf36400f7a
# Parent  bfa08dc02b3c7b265ead6019f901f17f925570c3
ico: reject obviously incorrect image sizes.

diff -r bfa08dc02b3c -r a1e9b624ca10 IMG_bmp.c
--- a/IMG_bmp.c	Wed Jan 24 12:00:24 2018 -0500
+++ b/IMG_bmp.c	Wed Jan 24 13:02:04 2018 -0500
@@ -735,6 +735,14 @@
         goto done;
     }
 
+    /* sanity check image size, so we don't overflow integers, etc. */
+    if ((biWidth < 0) || (biWidth > 0xFFFFFF) ||
+        (biHeight < 0) || (biHeight > 0xFFFFFF)) {
+        IMG_SetError("Unsupported or invalid ICO dimensions");
+        was_error = SDL_TRUE;
+        goto done;
+    }
+
     /* Create a RGBA surface */
     biHeight = biHeight >> 1;
     //printf("%d x %d\n", biWidth, biHeight);