mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 23:16:14 +01:00
Report an error if the file is too large. (#315275, Kjartan Maraas)
2005-09-05 Matthias Clasen <mclasen@redhat.com> * glib/gmappedfile.c (g_mapped_file_new): Report an error if the file is too large. (#315275, Kjartan Maraas)
This commit is contained in:
parent
d2ae3b0c0c
commit
38094ffb5c
@ -1,5 +1,8 @@
|
||||
2005-09-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gmappedfile.c (g_mapped_file_new): Report an error
|
||||
if the file is too large. (#315275, Kjartan Maraas)
|
||||
|
||||
* glib/gkeyfile.c (g_key_file_load_from_fd): The return value
|
||||
of read() is signed. (#315273, Kjartan Maraas)
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
2005-09-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gmappedfile.c (g_mapped_file_new): Report an error
|
||||
if the file is too large. (#315275, Kjartan Maraas)
|
||||
|
||||
* glib/gkeyfile.c (g_key_file_load_from_fd): The return value
|
||||
of read() is signed. (#315273, Kjartan Maraas)
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
2005-09-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gmappedfile.c (g_mapped_file_new): Report an error
|
||||
if the file is too large. (#315275, Kjartan Maraas)
|
||||
|
||||
* glib/gkeyfile.c (g_key_file_load_from_fd): The return value
|
||||
of read() is signed. (#315273, Kjartan Maraas)
|
||||
|
||||
|
@ -140,10 +140,17 @@ g_mapped_file_new (const gchar *filename,
|
||||
file->contents = MAP_FAILED;
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
file->length = st.st_size;
|
||||
file->contents = (gchar *) mmap (NULL, st.st_size,
|
||||
writable ? PROT_READ|PROT_WRITE : PROT_READ,
|
||||
MAP_PRIVATE, fd, 0);
|
||||
if (st.st_size > G_MAXSIZE)
|
||||
{
|
||||
errno = EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
file->length = (gsize) st.st_size;
|
||||
file->contents = (gchar *) mmap (NULL, file->length,
|
||||
writable ? PROT_READ|PROT_WRITE : PROT_READ,
|
||||
MAP_PRIVATE, fd, 0);
|
||||
}
|
||||
#endif
|
||||
#ifdef G_OS_WIN32
|
||||
file->length = st.st_size;
|
||||
|
Loading…
Reference in New Issue
Block a user