mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
Merge branch 'lillolollo-master-patch-25038' into 'master'
plug-ins/file-lnk avoid possible underflow See merge request GNOME/gimp!2118
This commit is contained in:
commit
dfcec81a23
1 changed files with 25 additions and 21 deletions
|
@ -252,29 +252,33 @@ load_image (GFile *file,
|
||||||
/* Length of the filename */
|
/* Length of the filename */
|
||||||
link_size = length - link_pos - 1;
|
link_size = length - link_pos - 1;
|
||||||
|
|
||||||
if (link_size > 0)
|
if (link_size <= 0) {
|
||||||
|
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
||||||
|
_("Invalid file."));
|
||||||
|
fclose (fp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar file_name[link_size];
|
||||||
|
|
||||||
|
/* Jump to link address and read in the real file name */
|
||||||
|
if (fseek (fp, base + link_pos, SEEK_SET) < 0 ||
|
||||||
|
fread (file_name, sizeof (gchar), link_size, fp) != link_size)
|
||||||
{
|
{
|
||||||
gchar file_name[link_size];
|
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
||||||
|
_("Invalid file."));
|
||||||
/* Jump to link address and read in the real file name */
|
fclose (fp);
|
||||||
if (fseek (fp, base + link_pos, SEEK_SET) < 0 ||
|
return NULL;
|
||||||
fread (file_name, sizeof (gchar), link_size, fp) != link_size)
|
|
||||||
{
|
|
||||||
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
|
||||||
_("Invalid file."));
|
|
||||||
fclose (fp);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
file_name[link_size - 1] = '\0';
|
|
||||||
image = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
|
|
||||||
g_file_new_for_path (file_name));
|
|
||||||
|
|
||||||
if (! image)
|
|
||||||
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
|
||||||
"%s", gimp_pdb_get_last_error (gimp_get_pdb ()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file_name[link_size - 1] = '\0';
|
||||||
|
image = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
|
||||||
|
g_file_new_for_path (file_name));
|
||||||
|
|
||||||
|
if (! image)
|
||||||
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
|
"%s", gimp_pdb_get_last_error (gimp_get_pdb ()));
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue