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:
Matthias Clasen 2005-09-05 18:20:24 +00:00 committed by Matthias Clasen
parent d2ae3b0c0c
commit 38094ffb5c
4 changed files with 20 additions and 4 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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;