app, plug-ins: move GIMP_BRUSH_MAX_SIZE to gimpbrush-header.h

and use it in the brush file plug-ins.
This commit is contained in:
Michael Natterer 2018-07-06 12:31:06 +02:00
parent e759ce3558
commit 8195a56261
7 changed files with 11 additions and 6 deletions

View File

@ -18,9 +18,12 @@
#ifndef __GIMP_BRUSH_HEADER_H__
#define __GIMP_BRUSH_HEADER_H__
#define GIMP_BRUSH_FILE_VERSION 2
#define GIMP_BRUSH_MAGIC (('G' << 24) + ('I' << 16) + \
('M' << 8) + ('P' << 0))
#define GIMP_BRUSH_MAX_SIZE 10000 /* Max size in either dimension in px */
/* All field entries are MSB */
@ -41,4 +44,5 @@ struct _GimpBrushHeader
* comes the brush data--width * height * bytes bytes of it...
*/
#endif /* __GIMP_BRUSH_HEADER_H__ */

View File

@ -21,7 +21,6 @@
#include "gimpdata.h"
#define GIMP_BRUSH_MAX_SIZE 10000 /* Max size in either dimension in px */
#define GIMP_TYPE_BRUSH (gimp_brush_get_type ())
#define GIMP_BRUSH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BRUSH, GimpBrush))

View File

@ -30,7 +30,7 @@
#include "gegl/gimp-babl.h"
#include "core/gimpbrush.h"
#include "core/gimpbrush-header.h"
#include "core/gimpbrushgenerated.h"
#include "core/gimpdrawable.h"
#include "core/gimpdynamics.h"

View File

@ -27,6 +27,7 @@
#include "paint-types.h"
#include "core/gimp.h"
#include "core/gimpbrush-header.h"
#include "core/gimpbrushgenerated.h"
#include "core/gimpimage.h"
#include "core/gimpdynamics.h"

View File

@ -29,6 +29,7 @@
#include "core/gimp-palettes.h"
#include "core/gimpbrush.h"
#include "core/gimpbrush-header.h"
#include "core/gimpdrawable.h"
#include "core/gimpdynamics.h"
#include "core/gimpimage.h"

View File

@ -386,8 +386,8 @@ load_image (GFile *file,
bh.bytes = g_ntohl (bh.bytes);
/* Sanitize values */
if ((bh.width == 0) || (bh.width > GIMP_MAX_IMAGE_SIZE) ||
(bh.height == 0) || (bh.height > GIMP_MAX_IMAGE_SIZE) ||
if ((bh.width == 0) || (bh.width > GIMP_BRUSH_MAX_SIZE) ||
(bh.height == 0) || (bh.height > GIMP_BRUSH_MAX_SIZE) ||
((bh.bytes != 1) && (bh.bytes != 2) && (bh.bytes != 4) &&
(bh.bytes != 18)) ||
(G_MAXSIZE / bh.width / bh.height / MAX (4, bh.bytes) < 1))

View File

@ -479,8 +479,8 @@ gih_load_one_brush (GInputStream *input,
bh.spacing = g_ntohl (bh.spacing);
/* Sanitize values */
if ((bh.width == 0) || (bh.width > GIMP_MAX_IMAGE_SIZE) ||
(bh.height == 0) || (bh.height > GIMP_MAX_IMAGE_SIZE) ||
if ((bh.width == 0) || (bh.width > GIMP_BRUSH_MAX_SIZE) ||
(bh.height == 0) || (bh.height > GIMP_BRUSH_MAX_SIZE) ||
((bh.bytes != 1) && (bh.bytes != 4)) ||
(G_MAXSIZE / bh.width / bh.height / bh.bytes < 1))
{