summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2022-08-09 16:10:40 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2022-08-09 16:21:48 +0100
commitb659038e4296534c2e068de9bce8d9e17fbe58b4 (patch)
treebd2babfc2a4b1a0e8db68eb85511646186fe83aa /gdk-pixbuf
parent8ad828c2782355c1747c62b3700bdc052e12e241 (diff)
downloadgdk-pixbuf-b659038e4296534c2e068de9bce8d9e17fbe58b4.tar.gz
jpeg: Limit the memory size when loading image data
Specially crafted JPEG images may lead to a crash when their size is too large; in the most benign of cases, the OS might terminate the process after it tries to allocate all the memory in the world. We can tell libjpeg to limit the size of the memory pool when loading, to avoid this kind of result. For the time being, 100 MB seems like a good threshold. Original patch by: Sam Ezeh <sam.z.ezeh@gmail.com> Fixes: #205
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/io-jpeg.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
index 48b163755..22f4174fe 100644
--- a/gdk-pixbuf/io-jpeg.c
+++ b/gdk-pixbuf/io-jpeg.c
@@ -1090,6 +1090,8 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data,
jpeg_save_markers (cinfo, JPEG_COM, 0xffff);
rc = jpeg_read_header (cinfo, TRUE);
context->src_initialized = TRUE;
+
+ cinfo->mem->max_memory_to_use = 100 * 1024 * 1024;
if (rc == JPEG_SUSPENDED)
continue;