mirror of https://github.com/GNOME/gimp.git
libgimp, libgimpconfig: use gimp_parasite_get_data().
As previously do not trust that parasite contents is proper text ending with nul character by always using the parasite size info.
This commit is contained in:
parent
ef3d4cddc4
commit
3e4407a315
|
@ -83,16 +83,16 @@ gimp_image_metadata_save_prepare (GimpImage *image,
|
||||||
|
|
||||||
if (metadata)
|
if (metadata)
|
||||||
{
|
{
|
||||||
GDateTime *datetime;
|
GDateTime *datetime;
|
||||||
const GimpParasite *comment_parasite;
|
GimpParasite *comment_parasite;
|
||||||
const gchar *comment = NULL;
|
gchar *comment = NULL;
|
||||||
gint image_width;
|
gint image_width;
|
||||||
gint image_height;
|
gint image_height;
|
||||||
gdouble xres;
|
gdouble xres;
|
||||||
gdouble yres;
|
gdouble yres;
|
||||||
gchar buffer[32];
|
gchar buffer[32];
|
||||||
gchar *str;
|
gchar *str;
|
||||||
GExiv2Metadata *g2metadata = GEXIV2_METADATA (metadata);
|
GExiv2Metadata *g2metadata = GEXIV2_METADATA (metadata);
|
||||||
|
|
||||||
image_width = gimp_image_width (image);
|
image_width = gimp_image_width (image);
|
||||||
image_height = gimp_image_height (image);
|
image_height = gimp_image_height (image);
|
||||||
|
@ -101,7 +101,14 @@ gimp_image_metadata_save_prepare (GimpImage *image,
|
||||||
|
|
||||||
comment_parasite = gimp_image_get_parasite (image, "gimp-comment");
|
comment_parasite = gimp_image_get_parasite (image, "gimp-comment");
|
||||||
if (comment_parasite)
|
if (comment_parasite)
|
||||||
comment = gimp_parasite_data (comment_parasite);
|
{
|
||||||
|
guint32 parasite_size;
|
||||||
|
|
||||||
|
comment = (gchar *) gimp_parasite_get_data (comment_parasite, ¶site_size);
|
||||||
|
comment = g_strndup (comment, parasite_size);
|
||||||
|
|
||||||
|
gimp_parasite_free (comment_parasite);
|
||||||
|
}
|
||||||
|
|
||||||
/* Exif */
|
/* Exif */
|
||||||
|
|
||||||
|
@ -198,7 +205,7 @@ gimp_image_metadata_save_prepare (GimpImage *image,
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
|
||||||
g_date_time_unref (datetime);
|
g_date_time_unref (datetime);
|
||||||
|
g_clear_pointer (&comment, g_free);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -326,8 +326,10 @@ gimp_procedure_config_get_parasite (GimpProcedureConfig *config,
|
||||||
|
|
||||||
if (parasite)
|
if (parasite)
|
||||||
{
|
{
|
||||||
value = g_strndup (gimp_parasite_data (parasite),
|
guint32 parasite_size;
|
||||||
gimp_parasite_data_size (parasite));
|
|
||||||
|
value = (gchar *) gimp_parasite_get_data (parasite, ¶site_size);
|
||||||
|
value = g_strndup (value, parasite_size);
|
||||||
gimp_parasite_free (parasite);
|
gimp_parasite_free (parasite);
|
||||||
|
|
||||||
if (value && ! strlen (value))
|
if (value && ! strlen (value))
|
||||||
|
@ -374,10 +376,11 @@ gimp_procedure_config_set_parasite (GimpProcedureConfig *config,
|
||||||
/* it there is a parasite, always override it if its value was
|
/* it there is a parasite, always override it if its value was
|
||||||
* changed
|
* changed
|
||||||
*/
|
*/
|
||||||
gchar *image_value;
|
gchar *image_value;
|
||||||
|
guint32 parasite_size;
|
||||||
|
|
||||||
image_value = g_strndup (gimp_parasite_data (parasite),
|
image_value = (gchar *) gimp_parasite_get_data (parasite, ¶site_size);
|
||||||
gimp_parasite_data_size (parasite));
|
image_value = g_strndup (image_value, parasite_size);
|
||||||
gimp_parasite_free (parasite);
|
gimp_parasite_free (parasite);
|
||||||
|
|
||||||
if (g_strcmp0 (value, image_value))
|
if (g_strcmp0 (value, image_value))
|
||||||
|
|
|
@ -623,18 +623,19 @@ gimp_config_deserialize_parasite (GimpConfig *config,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
const gchar *parasite_data;
|
||||||
|
guint32 parasite_size;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
|
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
|
||||||
g_return_val_if_fail (parasite != NULL, FALSE);
|
g_return_val_if_fail (parasite != NULL, FALSE);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
if (! gimp_parasite_data (parasite))
|
parasite_data = gimp_parasite_get_data (parasite, ¶site_size);
|
||||||
|
if (! parasite_data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return gimp_config_deserialize_string (config,
|
return gimp_config_deserialize_string (config, parasite_data, parasite_size,
|
||||||
gimp_parasite_data (parasite),
|
data, error);
|
||||||
gimp_parasite_data_size (parasite),
|
|
||||||
data,
|
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue