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 27, 2024
1 parent c9d436c commit 56f5e95
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 @@ -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)
Expand Down Expand Up @@ -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) ||
Expand Down

0 comments on commit 56f5e95

Please sign in to comment.