From f130fe1917e929fcdb83f58ab268687f571c5269 Mon Sep 17 00:00:00 2001 From: Jacob Boerema Date: Mon, 9 Aug 2021 16:32:55 -0400 Subject: [PATCH] app: disallow saving of patterns larger than max allowed dimensions For GIMP patterns we have maximum allowed dimensions which we check when loading a pattern. However, we did not check this when saving a pattern. See issue #6032. This commit adds a check when saving a pattern and adds a descriptive error to make clear why saving fails. --- app/core/gimppattern-save.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/core/gimppattern-save.c b/app/core/gimppattern-save.c index c745ab2063..b9ded3ea3d 100644 --- a/app/core/gimppattern-save.c +++ b/app/core/gimppattern-save.c @@ -26,6 +26,8 @@ #include "gimppattern-save.h" #include "gimptempbuf.h" +#include "gimp-intl.h" + gboolean gimp_pattern_save (GimpData *data, @@ -44,6 +46,15 @@ gimp_pattern_save (GimpData *data, width = gimp_temp_buf_get_width (mask); height = gimp_temp_buf_get_height (mask); + if (width > GIMP_PATTERN_MAX_SIZE || height > GIMP_PATTERN_MAX_SIZE) + { + g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, + _("Unsupported pattern dimensions %d x %d.\n" + "GIMP Patterns have a maximum size of %d x %d."), + width, height, + GIMP_PATTERN_MAX_SIZE, GIMP_PATTERN_MAX_SIZE); + return FALSE; + } header.header_size = g_htonl (sizeof (GimpPatternHeader) + strlen (name) + 1); header.version = g_htonl (1);