From 083c7c9116cec0e1d7e82f7537999c260705fa69 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 3 Sep 2001 00:26:06 +0000 Subject: [PATCH] app/plug_in.c app/core/gimpbrush.c app/core/gimpbrushpipe.c 2001-09-03 Sven Neumann * app/plug_in.c * app/core/gimpbrush.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: check strings from data files and plug-in registration for UTF-8 validity. There are probably a lot more places that need these checks. * plug-ins/common/gqbist.c: converted PDB texts to UTF-8. --- ChangeLog | 14 +++++++ app/actions/plug-in-commands.c | 55 +++++++++++++++++++++++++--- app/core/gimpbrush-load.c | 17 ++++++--- app/core/gimpbrush.c | 17 ++++++--- app/core/gimpbrushpipe-load.c | 14 ++++++- app/core/gimpbrushpipe.c | 14 ++++++- app/core/gimpgradient.c | 13 ++++++- app/core/gimppalette-load.c | 14 +++++-- app/core/gimppalette-save.c | 14 +++++-- app/core/gimppalette.c | 14 +++++-- app/core/gimppattern-load.c | 15 ++++++-- app/core/gimppattern.c | 15 ++++++-- app/gui/plug-in-commands.c | 55 +++++++++++++++++++++++++--- app/gui/plug-in-menus.c | 55 +++++++++++++++++++++++++--- app/menus/plug-in-menus.c | 55 +++++++++++++++++++++++++--- app/plug-in/gimpplugin-message.c | 55 +++++++++++++++++++++++++--- app/plug-in/gimpplugin-progress.c | 55 +++++++++++++++++++++++++--- app/plug-in/gimpplugin.c | 55 +++++++++++++++++++++++++--- app/plug-in/gimppluginmanager-call.c | 55 +++++++++++++++++++++++++--- app/plug-in/gimppluginmanager-run.c | 55 +++++++++++++++++++++++++--- app/plug-in/gimppluginmanager.c | 55 +++++++++++++++++++++++++--- app/plug-in/gimppluginshm.c | 55 +++++++++++++++++++++++++--- app/plug-in/plug-in-def.c | 55 +++++++++++++++++++++++++--- app/plug-in/plug-in-message.c | 55 +++++++++++++++++++++++++--- app/plug-in/plug-in-params.c | 55 +++++++++++++++++++++++++--- app/plug-in/plug-in-progress.c | 55 +++++++++++++++++++++++++--- app/plug-in/plug-in-run.c | 55 +++++++++++++++++++++++++--- app/plug-in/plug-in-shm.c | 55 +++++++++++++++++++++++++--- app/plug-in/plug-in.c | 55 +++++++++++++++++++++++++--- app/plug-in/plug-ins.c | 55 +++++++++++++++++++++++++--- app/plug_in.c | 55 +++++++++++++++++++++++++--- plug-ins/common/gqbist.c | 10 ++--- 32 files changed, 1130 insertions(+), 141 deletions(-) diff --git a/ChangeLog b/ChangeLog index c46bc2ca77..a7de930d0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,18 @@ +2001-09-03 Sven Neumann + + * app/plug_in.c + * app/core/gimpbrush.c + * app/core/gimpbrushpipe.c + * app/core/gimpgradient.c + * app/core/gimppalette.c + * app/core/gimppattern.c: check strings from data files and plug-in + registration for UTF-8 validity. There are probably a lot more places + that need these checks. + + * plug-ins/common/gqbist.c: converted PDB texts to UTF-8. + 2001-08-31 Thomas Canty + * app/colormaps.c * app/gdisplay.c * app/nav_window.c diff --git a/app/actions/plug-in-commands.c b/app/actions/plug-in-commands.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/actions/plug-in-commands.c +++ b/app/actions/plug-in-commands.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/core/gimpbrush-load.c b/app/core/gimpbrush-load.c index 8f300f480d..fbce63a5e0 100644 --- a/app/core/gimpbrush-load.c +++ b/app/core/gimpbrush-load.c @@ -429,7 +429,7 @@ gimp_brush_load_brush (gint fd, GimpBrush *brush; gint bn_size; BrushHeader header; - gchar *name; + gchar *name = NULL; gint i; g_return_val_if_fail (filename != NULL, NULL); @@ -477,11 +477,18 @@ gimp_brush_load_brush (gint fd, g_free (name); return NULL; } + + if (!g_utf8_validate (name, -1, NULL)) + { + g_message (_("Invalid UTF-8 string in GIMP brush file \"%s\"."), + filename); + g_free (name); + name = NULL; + } } - else - { - name = g_strdup (_("Unnamed")); - } + + if (!name) + name = g_strdup (_("Unnamed")); switch (header.bytes) { diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c index 8f300f480d..fbce63a5e0 100644 --- a/app/core/gimpbrush.c +++ b/app/core/gimpbrush.c @@ -429,7 +429,7 @@ gimp_brush_load_brush (gint fd, GimpBrush *brush; gint bn_size; BrushHeader header; - gchar *name; + gchar *name = NULL; gint i; g_return_val_if_fail (filename != NULL, NULL); @@ -477,11 +477,18 @@ gimp_brush_load_brush (gint fd, g_free (name); return NULL; } + + if (!g_utf8_validate (name, -1, NULL)) + { + g_message (_("Invalid UTF-8 string in GIMP brush file \"%s\"."), + filename); + g_free (name); + name = NULL; + } } - else - { - name = g_strdup (_("Unnamed")); - } + + if (!name) + name = g_strdup (_("Unnamed")); switch (header.bytes) { diff --git a/app/core/gimpbrushpipe-load.c b/app/core/gimpbrushpipe-load.c index d8d0d2e055..4572048fbd 100644 --- a/app/core/gimpbrushpipe-load.c +++ b/app/core/gimpbrushpipe-load.c @@ -300,13 +300,23 @@ gimp_brush_pipe_load (const gchar *filename) if (buffer->len > 0 && buffer->len < 1024) { pipe = GIMP_BRUSH_PIPE (g_object_new (GIMP_TYPE_BRUSH_PIPE, NULL)); - gimp_object_set_name (GIMP_OBJECT (pipe), buffer->str); + + if (g_utf8_validate (buffer->str, buffer->len, NULL)) + { + gimp_object_set_name (GIMP_OBJECT (pipe), buffer->str); + } + else + { + g_message (_("Invalid UTF-8 string in GIMP brush file \"%s\"."), + filename); + gimp_object_set_name (GIMP_OBJECT (pipe), _("Unnamed")); + } } g_string_free (buffer, TRUE); if (!pipe) { - g_message ("Couldn't read name for brush pipe from file '%s'\n", + g_message ("Couldn't read name for brush pipe from file \"%s\".\n", filename); close (fd); return NULL; diff --git a/app/core/gimpbrushpipe.c b/app/core/gimpbrushpipe.c index d8d0d2e055..4572048fbd 100644 --- a/app/core/gimpbrushpipe.c +++ b/app/core/gimpbrushpipe.c @@ -300,13 +300,23 @@ gimp_brush_pipe_load (const gchar *filename) if (buffer->len > 0 && buffer->len < 1024) { pipe = GIMP_BRUSH_PIPE (g_object_new (GIMP_TYPE_BRUSH_PIPE, NULL)); - gimp_object_set_name (GIMP_OBJECT (pipe), buffer->str); + + if (g_utf8_validate (buffer->str, buffer->len, NULL)) + { + gimp_object_set_name (GIMP_OBJECT (pipe), buffer->str); + } + else + { + g_message (_("Invalid UTF-8 string in GIMP brush file \"%s\"."), + filename); + gimp_object_set_name (GIMP_OBJECT (pipe), _("Unnamed")); + } } g_string_free (buffer, TRUE); if (!pipe) { - g_message ("Couldn't read name for brush pipe from file '%s'\n", + g_message ("Couldn't read name for brush pipe from file \"%s\".\n", filename); close (fd); return NULL; diff --git a/app/core/gimpgradient.c b/app/core/gimpgradient.c index 171fda90e8..8d7b616a16 100644 --- a/app/core/gimpgradient.c +++ b/app/core/gimpgradient.c @@ -320,8 +320,17 @@ gimp_gradient_load (const gchar *filename) fgets (line, 1024, file); if (! strncmp (line, "Name: ", strlen ("Name: "))) { - gimp_object_set_name (GIMP_OBJECT (gradient), - g_strstrip (&line[strlen ("Name: ")])); + if (g_utf8_validate (line, -1, NULL)) + { + gimp_object_set_name (GIMP_OBJECT (gradient), + g_strstrip (&line[strlen ("Name: ")])); + } + else + { + g_message (_("Invalid UTF-8 string in GIMP gradient file \"%s\"."), + filename); + gimp_object_set_name (GIMP_OBJECT (gradient), _("Unnamed")); + } fgets (line, 1024, file); } diff --git a/app/core/gimppalette-load.c b/app/core/gimppalette-load.c index dcfc336f85..b920748bb5 100644 --- a/app/core/gimppalette-load.c +++ b/app/core/gimppalette-load.c @@ -301,8 +301,16 @@ gimp_palette_load (const gchar *filename) if (! strncmp (str, "Name: ", strlen ("Name: "))) { - gimp_object_set_name (GIMP_OBJECT (palette), - g_strstrip (&str[strlen ("Name: ")])); + if (g_utf8_validate (str, -1, NULL)) + { + gimp_object_set_name (GIMP_OBJECT (palette), + g_strstrip (&str[strlen ("Name: ")])); + } + else + { + g_message (_("Invalid UTF-8 string in palette file '%s'"), filename); + gimp_object_set_name (GIMP_OBJECT (palette), _("Unnamed")); + } if (! fgets (str, 1024, fp)) { @@ -487,7 +495,6 @@ gimp_palette_add_entry (GimpPalette *palette, { GimpPaletteEntry *entry; - g_return_val_if_fail (palette != NULL, NULL); g_return_val_if_fail (GIMP_IS_PALETTE (palette), NULL); g_return_val_if_fail (color != NULL, NULL); @@ -514,7 +521,6 @@ gimp_palette_delete_entry (GimpPalette *palette, GList *list; gint pos = 0; - g_return_if_fail (palette != NULL); g_return_if_fail (GIMP_IS_PALETTE (palette)); g_return_if_fail (entry != NULL); diff --git a/app/core/gimppalette-save.c b/app/core/gimppalette-save.c index dcfc336f85..b920748bb5 100644 --- a/app/core/gimppalette-save.c +++ b/app/core/gimppalette-save.c @@ -301,8 +301,16 @@ gimp_palette_load (const gchar *filename) if (! strncmp (str, "Name: ", strlen ("Name: "))) { - gimp_object_set_name (GIMP_OBJECT (palette), - g_strstrip (&str[strlen ("Name: ")])); + if (g_utf8_validate (str, -1, NULL)) + { + gimp_object_set_name (GIMP_OBJECT (palette), + g_strstrip (&str[strlen ("Name: ")])); + } + else + { + g_message (_("Invalid UTF-8 string in palette file '%s'"), filename); + gimp_object_set_name (GIMP_OBJECT (palette), _("Unnamed")); + } if (! fgets (str, 1024, fp)) { @@ -487,7 +495,6 @@ gimp_palette_add_entry (GimpPalette *palette, { GimpPaletteEntry *entry; - g_return_val_if_fail (palette != NULL, NULL); g_return_val_if_fail (GIMP_IS_PALETTE (palette), NULL); g_return_val_if_fail (color != NULL, NULL); @@ -514,7 +521,6 @@ gimp_palette_delete_entry (GimpPalette *palette, GList *list; gint pos = 0; - g_return_if_fail (palette != NULL); g_return_if_fail (GIMP_IS_PALETTE (palette)); g_return_if_fail (entry != NULL); diff --git a/app/core/gimppalette.c b/app/core/gimppalette.c index dcfc336f85..b920748bb5 100644 --- a/app/core/gimppalette.c +++ b/app/core/gimppalette.c @@ -301,8 +301,16 @@ gimp_palette_load (const gchar *filename) if (! strncmp (str, "Name: ", strlen ("Name: "))) { - gimp_object_set_name (GIMP_OBJECT (palette), - g_strstrip (&str[strlen ("Name: ")])); + if (g_utf8_validate (str, -1, NULL)) + { + gimp_object_set_name (GIMP_OBJECT (palette), + g_strstrip (&str[strlen ("Name: ")])); + } + else + { + g_message (_("Invalid UTF-8 string in palette file '%s'"), filename); + gimp_object_set_name (GIMP_OBJECT (palette), _("Unnamed")); + } if (! fgets (str, 1024, fp)) { @@ -487,7 +495,6 @@ gimp_palette_add_entry (GimpPalette *palette, { GimpPaletteEntry *entry; - g_return_val_if_fail (palette != NULL, NULL); g_return_val_if_fail (GIMP_IS_PALETTE (palette), NULL); g_return_val_if_fail (color != NULL, NULL); @@ -514,7 +521,6 @@ gimp_palette_delete_entry (GimpPalette *palette, GList *list; gint pos = 0; - g_return_if_fail (palette != NULL); g_return_if_fail (GIMP_IS_PALETTE (palette)); g_return_if_fail (entry != NULL); diff --git a/app/core/gimppattern-load.c b/app/core/gimppattern-load.c index 090f4f583b..552f0742a7 100644 --- a/app/core/gimppattern-load.c +++ b/app/core/gimppattern-load.c @@ -312,11 +312,18 @@ gimp_pattern_load (const gchar *filename) g_message (_("Error in GIMP pattern file \"%s\"."), filename); goto error; } + + if (!g_utf8_validate (name, -1, NULL)) + { + g_message (_("Invalid UTF-8 string in GIMP pattern file \"%s\"."), + filename); + g_free (name); + name = NULL; + } } - else - { - name = g_strdup (_("Unnamed")); - } + + if (!name) + name = g_strdup (_("Unnamed")); pattern = GIMP_PATTERN (g_object_new (GIMP_TYPE_PATTERN, NULL)); diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c index 090f4f583b..552f0742a7 100644 --- a/app/core/gimppattern.c +++ b/app/core/gimppattern.c @@ -312,11 +312,18 @@ gimp_pattern_load (const gchar *filename) g_message (_("Error in GIMP pattern file \"%s\"."), filename); goto error; } + + if (!g_utf8_validate (name, -1, NULL)) + { + g_message (_("Invalid UTF-8 string in GIMP pattern file \"%s\"."), + filename); + g_free (name); + name = NULL; + } } - else - { - name = g_strdup (_("Unnamed")); - } + + if (!name) + name = g_strdup (_("Unnamed")); pattern = GIMP_PATTERN (g_object_new (GIMP_TYPE_PATTERN, NULL)); diff --git a/app/gui/plug-in-commands.c b/app/gui/plug-in-commands.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/gui/plug-in-commands.c +++ b/app/gui/plug-in-commands.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/gui/plug-in-menus.c b/app/gui/plug-in-menus.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/gui/plug-in-menus.c +++ b/app/gui/plug-in-menus.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/menus/plug-in-menus.c +++ b/app/menus/plug-in-menus.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/gimpplugin-progress.c b/app/plug-in/gimpplugin-progress.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/gimpplugin-progress.c +++ b/app/plug-in/gimpplugin-progress.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/gimppluginmanager-call.c +++ b/app/plug-in/gimppluginmanager-call.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/gimppluginmanager-run.c b/app/plug-in/gimppluginmanager-run.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/gimppluginmanager-run.c +++ b/app/plug-in/gimppluginmanager-run.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/gimppluginshm.c b/app/plug-in/gimppluginshm.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/gimppluginshm.c +++ b/app/plug-in/gimppluginshm.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/plug-in-def.c b/app/plug-in/plug-in-def.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/plug-in-def.c +++ b/app/plug-in/plug-in-def.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/plug-in-message.c b/app/plug-in/plug-in-message.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/plug-in-message.c +++ b/app/plug-in/plug-in-message.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/plug-in-params.c b/app/plug-in/plug-in-params.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/plug-in-params.c +++ b/app/plug-in/plug-in-params.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/plug-in-progress.c b/app/plug-in/plug-in-progress.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/plug-in-progress.c +++ b/app/plug-in/plug-in-progress.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/plug-in-run.c b/app/plug-in/plug-in-run.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/plug-in-run.c +++ b/app/plug-in/plug-in-run.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/plug-in-shm.c b/app/plug-in/plug-in-shm.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/plug-in-shm.c +++ b/app/plug-in/plug-in-shm.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/plug-in.c b/app/plug-in/plug-in.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/plug-in.c +++ b/app/plug-in/plug-in.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/app/plug_in.c b/app/plug_in.c index c62d73f1bc..1c8b8fc0b4 100644 --- a/app/plug_in.c +++ b/app/plug_in.c @@ -1833,6 +1833,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) GSList *tmp = NULL; gchar *prog = NULL; gboolean add_proc_def; + gboolean valid; gint i; /* Argument checking @@ -1890,10 +1891,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) else if (strncmp (proc_install->menu_path, "", 6) == 0) { if ((proc_install->nparams < 5) || - (proc_install->params[0].type != GIMP_PDB_INT32) || - (proc_install->params[1].type != GIMP_PDB_IMAGE) || + (proc_install->params[0].type != GIMP_PDB_INT32) || + (proc_install->params[1].type != GIMP_PDB_IMAGE) || (proc_install->params[2].type != GIMP_PDB_DRAWABLE) || - (proc_install->params[3].type != GIMP_PDB_STRING) || + (proc_install->params[3].type != GIMP_PDB_STRING) || (proc_install->params[4].type != GIMP_PDB_STRING)) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1924,9 +1925,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) for (i = 1; i < proc_install->nparams; i++) { if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY || - proc_install->params[i].type == GIMP_PDB_INT8ARRAY || + proc_install->params[i].type == GIMP_PDB_INT8ARRAY || proc_install->params[i].type == GIMP_PDB_FLOATARRAY || - proc_install->params[i].type == GIMP_PDB_STRINGARRAY) && + proc_install->params[i].type == GIMP_PDB_STRINGARRAY) + && proc_install->params[i-1].type != GIMP_PDB_INT32) { g_message ("Plug-In \"%s\"\n(%s)\n" @@ -1939,7 +1941,50 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) return; } } + + /* Sanity check strings for UTF-8 validity */ + valid = FALSE; + + if ((proc_install->menu_path == NULL || + g_utf8_validate (proc_install->menu_path, -1, NULL)) && + (g_utf8_validate (proc_install->name, -1, NULL)) && + (proc_install->blurb == NULL || + g_utf8_validate (proc_install->blurb, -1, NULL)) && + (proc_install->help == NULL || + g_utf8_validate (proc_install->help, -1, NULL)) && + (proc_install->author == NULL || + g_utf8_validate (proc_install->author, -1, NULL)) && + (proc_install->copyright == NULL || + g_utf8_validate (proc_install->copyright, -1, NULL)) && + (proc_install->date == NULL || + g_utf8_validate (proc_install->date, -1, NULL))) + { + valid = TRUE; + + for (i = 0; i < proc_install->nparams && valid; i++) + { + if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) && + (proc_install->params[i].description == NULL || + g_utf8_validate (proc_install->params[i].description, -1, NULL)))) + valid = FALSE; + } + for (i = 0; i < proc_install->nreturn_vals && valid; i++) + { + if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) && + (proc_install->return_vals[i].description == NULL || + g_utf8_validate (proc_install->return_vals[i].description, -1, NULL)))) + valid = FALSE; + } + } + if (!valid) + { + g_message ("Plug-In \"%s\"\n(%s)\n" + "attempted to install a procedure with invalid UTF-8 strings.\n", + g_path_get_basename (current_plug_in->args[0]), + current_plug_in->args[0]); + return; + } /* Initialization */ diff --git a/plug-ins/common/gqbist.c b/plug-ins/common/gqbist.c index 7c9d11e9a0..12ae0f2458 100644 --- a/plug-ins/common/gqbist.c +++ b/plug-ins/common/gqbist.c @@ -4,8 +4,8 @@ * Jörn Loviscach. * * It appeared in c't 10/95, page 326 and is called - * "Ausgewürfelt - Moderne Kunst algorithmisch erzeugen". - * (~modern art created with algorithms) + * "Ausgewürfelt - Moderne Kunst algorithmisch erzeugen" + * (~modern art created with algorithms). * * It generates one main formula (the middle button) and 8 variations of it. * If you select a variation it becomes the new main formula. If you @@ -416,9 +416,9 @@ query (void) gimp_install_procedure (PLUG_IN_NAME, "Create images based on a random genetic formula", - "This Plug-in is based on an article by Jörn Loviscach (appeared in c't 10/95, page 326). It generates modern art pictures from a random genetic formula.", - "Jörn Loviscach, Jens Ch. Restemeier", - "Jörn Loviscach, Jens Ch. Restemeier", + "This Plug-in is based on an article by Jörn Loviscach (appeared in c't 10/95, page 326). It generates modern art pictures from a random genetic formula.", + "Jörn Loviscach, Jens Ch. Restemeier", + "Jörn Loviscach, Jens Ch. Restemeier", PLUG_IN_VERSION, N_("/Filters/Render/Pattern/Qbist..."), "RGB*",