mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 11:12:11 +01:00
Detect overflow and error out. Reported by Morten Welinder.
* glib/gfileutils.c (get_contents_stdio): Detect overflow and error out. Reported by Morten Welinder. svn path=/trunk/; revision=7194
This commit is contained in:
parent
c0dbb1c772
commit
6c2c99aa0e
@ -1,3 +1,10 @@
|
||||
2008-07-16 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Bug 482413 - get_contents_stdio -- overflow and memory corruption
|
||||
|
||||
* glib/gfileutils.c (get_contents_stdio): Detect overflow and
|
||||
error out. Reported by Morten Welinder.
|
||||
|
||||
2008-07-16 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Bug 542332 – small fix for error message in GMarkup
|
||||
|
@ -577,13 +577,28 @@ get_contents_stdio (const gchar *display_filename,
|
||||
}
|
||||
|
||||
memcpy (str + total_bytes, buf, bytes);
|
||||
|
||||
if (total_bytes + bytes < total_bytes)
|
||||
{
|
||||
g_set_error (error,
|
||||
G_FILE_ERROR,
|
||||
G_FILE_ERROR_FAILED,
|
||||
_("File \"%s\" is too large"),
|
||||
display_filename);
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
total_bytes += bytes;
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
|
||||
if (total_allocated == 0)
|
||||
str = g_new (gchar, 1);
|
||||
{
|
||||
str = g_new (gchar, 1);
|
||||
total_bytes = 0;
|
||||
}
|
||||
|
||||
str[total_bytes] = '\0';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user