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.
This commit is contained in:
Jacob Boerema 2021-08-09 16:32:55 -04:00
parent 7bb892f3d5
commit f130fe1917
1 changed files with 11 additions and 0 deletions

View File

@ -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);