[gimp/gimp-2-10] app: disallow saving of patterns larger than max allowed dimensions
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: disallow saving of patterns larger than max allowed dimensions
- Date: Mon, 9 Aug 2021 22:28:45 +0000 (UTC)
commit d9e82494b4204f467c63f5df7a19019292a2a3a4
Author: Jacob Boerema <jgboerema gmail com>
Date: Mon Aug 9 16:32:55 2021 -0400
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.
(cherry picked from commit f130fe1917e929fcdb83f58ab268687f571c5269)
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]