mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-04 01:58:54 +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:
		
				
					committed by
					
						
						Matthias Clasen
					
				
			
			
				
	
			
			
			
						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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user