From 56f5e95a9608d02b7b4ea50afd2e9854e68d9cc9 Mon Sep 17 00:00:00 2001 From: Julian Sparber Date: Thu, 11 Jul 2024 11:34:48 +0200 Subject: [PATCH] validate-icon: Add file limit of 4MB Images shouldn't be to big in size. 4MBs is more then enough for all cases. --- src/validate-icon.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/validate-icon.c b/src/validate-icon.c index 4c73fc7d3..862f864f7 100644 --- a/src/validate-icon.c +++ b/src/validate-icon.c @@ -39,6 +39,7 @@ #define MAX_ICON_SIZE 512 #define MAX_SVG_ICON_SIZE 4096 #define BUFFER_SIZE 4096 +#define MAX_FILE_SIZE 4194304 /* Max file size of 4MB */ static int validate_icon (int input_fd) @@ -72,6 +73,12 @@ validate_icon (int input_fd) return 1; } + if (g_bytes_get_size (bytes) > MAX_FILE_SIZE) + { + g_printerr ("Image is bigger then the allowed size\n"); + return 1; + } + loader = gdk_pixbuf_loader_new (); if (!gdk_pixbuf_loader_write_bytes (loader, bytes, &error) ||