Commit 5559b622 authored by Shlomi Fish's avatar Shlomi Fish
Browse files

fixed bug #148088: ("Gimpressioinst crashes if given malicious presets

* plug-ins/gimpressionist/: fixed bug #148088: ("Gimpressioinst crashes if
given malicious presets with out of range values, in the radio buttons
group numeric values: "placetype", "orienttype", etc. ").

This was done by adding clamps to the relevant values in the preset.
parent 3c6ed976
2004-07-25 Shlomi Fish <shlomif@iglu.org.il>
* plug-ins/gimpressionist/: fixed bug #148088: ("Gimpressioinst crashes if
given malicious presets with out of range values, in the radio buttons
group numeric values: "placetype", "orienttype", etc. ").
This was done by adding clamps to the relevant values in the preset.
2004-07-25 Raphaël Quinet <quinet@gamers.org>
* INSTALL: Minor fixes and improvements. Suggest using a
......
......@@ -23,6 +23,11 @@ void color_restore(void)
gtk_adjustment_set_value(GTK_ADJUSTMENT(colornoiseadjust), pcvals.colornoise);
}
int color_type_input (int in)
{
return CLAMP_UP_TO (in, NUMCOLORRADIO);
}
void create_colorpage(GtkNotebook *notebook)
{
GtkWidget *vbox;
......
......@@ -7,8 +7,9 @@ enum COLOR_TYPE_ENUM
COLOR_TYPE_CENTER = 1,
};
void create_colorpage(GtkNotebook *);
void color_restore(void);
void create_colorpage (GtkNotebook *);
void color_restore (void);
int color_type_input (int in);
#endif /* #ifndef __COLOR_H */
......@@ -50,6 +50,11 @@ void general_store(void)
pcvals.devthresh = GTK_ADJUSTMENT(dev_thresh_adjust)->value;
}
int general_bg_type_input (int in)
{
return CLAMP_UP_TO (in, NUMGENERALBGRADIO);
}
void general_restore(void)
{
gtk_toggle_button_set_active (
......
......@@ -4,5 +4,6 @@
void general_restore(void);
void general_store(void);
void create_generalpage(GtkNotebook *);
int general_bg_type_input (int in);
#endif /* #ifndef __GENERAL_H */
......@@ -17,8 +17,6 @@
#define MAXORIENTVECT 50
#define MAXSIZEVECT 50
#define NUMSIZERADIO 8
/* Type declaration and definitions */
typedef struct vector
......@@ -154,9 +152,11 @@ void restore_default_values (void);
GtkWidget *create_radio_button (GtkWidget *box, int orienttype,
void (*callback)(GtkWidget *wg, void *d),
gchar *label, gchar *help_string,
GSList **radio_group,
GSList **radio_group,
GtkWidget **buttons_array
);
#define CLAMP_UP_TO(x, max) (CLAMP((x),(0),(max-1)))
#endif /* #ifndef __GIMPRESSIONIST_H */
......@@ -21,6 +21,11 @@ static void orientation_store (GtkWidget *wg, void *d)
pcvals.orienttype = GPOINTER_TO_INT (d);
}
int orientation_type_input (int in)
{
return CLAMP_UP_TO (in, NUMORIENTRADIO);
}
void orientation_restore(void)
{
gtk_toggle_button_set_active (
......
......@@ -17,5 +17,6 @@ enum ORIENTATION_ENUM
void create_orientationpage (GtkNotebook *);
void orientation_restore (void);
int orientation_type_input (int in);
#endif /* #ifndef __ORIENTATION_H */
......@@ -24,6 +24,11 @@ void place_restore()
gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_density_adjust), pcvals.brushdensity);
}
int place_type_input (int in)
{
return CLAMP_UP_TO(in, NUM_PLACE_RADIO);
}
void place_store()
{
pcvals.placement_center = GTK_TOGGLE_BUTTON (placement_center)->active;
......
......@@ -7,8 +7,9 @@ enum PLACEMENT_TYPE_ENUM
PLACEMENT_TYPE_EVEN_DIST = 1,
};
void place_store(void);
void place_restore(void);
void create_placementpage(GtkNotebook *);
void place_store (void);
void place_restore (void);
void create_placementpage (GtkNotebook *);
int place_type_input (int in);
#endif
......@@ -17,6 +17,13 @@
#include "gimpressionist.h"
#include "presets.h"
#include "color.h"
#include "general.h"
#include "orientation.h"
#include "placement.h"
#include "size.h"
#include "libgimp/stdplugins-intl.h"
#ifdef G_OS_WIN32
......@@ -298,7 +305,7 @@ static void set_values (const gchar *key, const gchar *val)
else if(!strcmp(key, "orientlast"))
pcvals.orientlast = g_ascii_strtod (val, NULL);
else if(!strcmp(key, "orienttype"))
pcvals.orienttype = atoi(val);
pcvals.orienttype = orientation_type_input (atoi (val));
else if(!strcmp(key, "sizenum"))
pcvals.sizenum = atoi(val);
......@@ -307,7 +314,7 @@ static void set_values (const gchar *key, const gchar *val)
else if(!strcmp(key, "sizelast"))
pcvals.sizelast = g_ascii_strtod (val, NULL);
else if(!strcmp(key, "sizetype"))
pcvals.sizetype = atoi(val);
pcvals.sizetype = size_type_input (atoi (val));
else if(!strcmp(key, "brushrelief"))
pcvals.brushrelief = g_ascii_strtod (val, NULL);
......@@ -324,7 +331,7 @@ static void set_values (const gchar *key, const gchar *val)
pcvals.brushaspect = g_ascii_strtod (val, NULL);
else if(!strcmp(key, "generalbgtype"))
pcvals.generalbgtype = atoi(val);
pcvals.generalbgtype = general_bg_type_input (atoi(val));
else if(!strcmp(key, "generaldarkedge"))
pcvals.generaldarkedge = g_ascii_strtod (val, NULL);
else if(!strcmp(key, "generalpaintedges"))
......@@ -352,7 +359,7 @@ static void set_values (const gchar *key, const gchar *val)
pcvals.paper_overlay = atoi(val);
else if(!strcmp(key, "placetype"))
pcvals.placetype = atoi(val);
pcvals.placetype = place_type_input (atoi (val));
else if(!strcmp(key, "placecenter"))
pcvals.placement_center = atoi(val);
......@@ -387,7 +394,7 @@ static void set_values (const gchar *key, const gchar *val)
pcvals.sizevoronoi = atoi(val);
else if(!strcmp(key, "colortype"))
pcvals.colortype = atoi(val);
pcvals.colortype = color_type_input (atoi (val));
else if(!strcmp(key, "colornoise"))
pcvals.colornoise = g_ascii_strtod (val, NULL);
}
......
......@@ -11,6 +11,8 @@
#include "libgimp/stdplugins-intl.h"
#define NUMSIZERADIO 8
static GtkObject *sizenumadjust = NULL;
static GtkObject *sizefirstadjust = NULL;
static GtkObject *sizelastadjust = NULL;
......@@ -21,6 +23,11 @@ static void size_store(GtkWidget *wg, void *d)
pcvals.sizetype = GPOINTER_TO_INT (d);
}
int size_type_input (int in)
{
return CLAMP_UP_TO(in, NUMSIZERADIO);
}
static void size_type_restore(void)
{
gtk_toggle_button_set_active (
......@@ -28,6 +35,7 @@ static void size_type_restore(void)
TRUE
);
}
void size_restore(void)
{
size_type_restore();
......
......@@ -13,8 +13,10 @@ enum SIZE_TYPE_ENUM
SIZE_TYPE_MANUAL = 7,
};
void size_restore(void);
void size_restore (void);
void create_sizepage(GtkNotebook *);
void create_sizepage (GtkNotebook *);
int size_type_input (int in);
#endif /* #ifndef __SIZE_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment