Skip to content

Commit

Permalink
validate-icon: Add file limit of 4MB
Browse files Browse the repository at this point in the history
Images shouldn't be to big in size. 4MBs is more then enough for all
cases.
  • Loading branch information
jsparber committed Aug 29, 2024
1 parent 2e19f6f commit eb346c6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/validate-icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define MAX_ICON_SIZE 512
#define MAX_SVG_ICON_SIZE 4096
#define BUFFER_SIZE 4096
#define MAX_FILE_SIZE (1024 * 1024 * 4) /* Max file size of 4MiB */

static int
validate_icon (int input_fd)
Expand Down Expand Up @@ -75,6 +76,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))
Expand Down

0 comments on commit eb346c6

Please sign in to comment.