summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/libsdl2/libsdl2/CVE-2020-14409-14410.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-graphics/libsdl2/libsdl2/CVE-2020-14409-14410.patch')
-rw-r--r--meta/recipes-graphics/libsdl2/libsdl2/CVE-2020-14409-14410.patch79
1 files changed, 79 insertions, 0 deletions
diff --git a/meta/recipes-graphics/libsdl2/libsdl2/CVE-2020-14409-14410.patch b/meta/recipes-graphics/libsdl2/libsdl2/CVE-2020-14409-14410.patch
new file mode 100644
index 0000000000..d8fa24bc65
--- /dev/null
+++ b/meta/recipes-graphics/libsdl2/libsdl2/CVE-2020-14409-14410.patch
@@ -0,0 +1,79 @@
1From a7ff6e96155f550a5597621ebeddd03c98aa9294 Mon Sep 17 00:00:00 2001
2From: Sam Lantinga <slouken@libsdl.org>
3Date: Wed, 17 Jun 2020 08:44:45 -0700
4Subject: [PATCH] Fixed overflow in surface pitch calculation
5
6
7Upstream-Status: Backport
8[https://github.com/libsdl-org/SDL/commit/a7ff6e96155f550a5597621ebeddd03c98aa9294]
9CVE: CVE-2020-14409 CVE-2020-14410
10Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
11
12---
13 src/video/SDL_surface.c | 23 +++++++++++++++--------
14 1 file changed, 15 insertions(+), 8 deletions(-)
15
16diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
17index 085d9ff1e..bff826f7c 100644
18--- a/src/video/SDL_surface.c
19+++ b/src/video/SDL_surface.c
20@@ -28,24 +28,23 @@
21 #include "SDL_yuv_c.h"
22
23
24-/* Check to make sure we can safely check multiplication of surface w and pitch and it won't overflow size_t */
25-SDL_COMPILE_TIME_ASSERT(surface_size_assumptions,
26- sizeof(int) == sizeof(Sint32) && sizeof(size_t) >= sizeof(Sint32));
27+/* Check to make sure we can safely check multiplication of surface w and pitch and it won't overflow Sint64 */
28+SDL_COMPILE_TIME_ASSERT(surface_size_assumptions, sizeof(int) == sizeof(Sint32));
29
30 /* Public routines */
31
32 /*
33 * Calculate the pad-aligned scanline width of a surface
34 */
35-static int
36+static Sint64
37 SDL_CalculatePitch(Uint32 format, int width)
38 {
39- int pitch;
40+ Sint64 pitch;
41
42 if (SDL_ISPIXELFORMAT_FOURCC(format) || SDL_BITSPERPIXEL(format) >= 8) {
43- pitch = (width * SDL_BYTESPERPIXEL(format));
44+ pitch = ((Sint64)width * SDL_BYTESPERPIXEL(format));
45 } else {
46- pitch = ((width * SDL_BITSPERPIXEL(format)) + 7) / 8;
47+ pitch = (((Sint64)width * SDL_BITSPERPIXEL(format)) + 7) / 8;
48 }
49 pitch = (pitch + 3) & ~3; /* 4-byte aligning for speed */
50 return pitch;
51@@ -59,11 +58,19 @@ SDL_Surface *
52 SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
53 Uint32 format)
54 {
55+ Sint64 pitch;
56 SDL_Surface *surface;
57
58 /* The flags are no longer used, make the compiler happy */
59 (void)flags;
60
61+ pitch = SDL_CalculatePitch(format, width);
62+ if (pitch < 0 || pitch > SDL_MAX_SINT32) {
63+ /* Overflow... */
64+ SDL_OutOfMemory();
65+ return NULL;
66+ }
67+
68 /* Allocate the surface */
69 surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface));
70 if (surface == NULL) {
71@@ -78,7 +85,7 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
72 }
73 surface->w = width;
74 surface->h = height;
75- surface->pitch = SDL_CalculatePitch(format, width);
76+ surface->pitch = (int)pitch;
77 SDL_SetClipRect(surface, NULL);
78
79 if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {