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