Files
mtkports/www-client/netsurf/patches/0013-bitmap-rowstride-and-bounds.patch
T

22 lines
695 B
Diff

diff --git a/frontends/monkey/bitmap.c b/frontends/monkey/bitmap.c
index cc13c8b..60104ec 100644
--- a/frontends/monkey/bitmap.c
+++ b/frontends/monkey/bitmap.c
@@ -36,12 +36,16 @@ struct bitmap {
static void *bitmap_create(int width, int height, enum gui_bitmap_flags flags)
{
+ if (width <= 0 || height <= 0 || width > 8192 || height > 8192 ||
+ (size_t)width * (size_t)height > 32u * 1024u * 1024u)
+ return NULL;
struct bitmap *ret = calloc(1, sizeof(*ret));
if (ret == NULL)
return NULL;
ret->width = width;
ret->height = height;
+ ret->rowstride = (size_t)width * 4;
ret->opaque = (flags & BITMAP_OPAQUE) == BITMAP_OPAQUE;
ret->ptr = calloc(width, height * 4);