[dovecot-cvs] dovecot/src/lib file-cache.c,1.2,1.3

cras at dovecot.org cras at dovecot.org
Mon Nov 29 14:21:26 EET 2004


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv10606/lib

Modified Files:
	file-cache.c 
Log Message:
Don't crash if trying to read more than INT_MAX bytes. Just silently allow
it.



Index: file-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/file-cache.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- file-cache.c	8 Nov 2004 01:02:52 -0000	1.2
+++ file-cache.c	29 Nov 2004 12:21:24 -0000	1.3
@@ -49,7 +49,12 @@
 	unsigned char *bits, *dest;
 	ssize_t ret;
 
-	i_assert(size < INT_MAX);
+	if (size > SSIZE_T_MAX) {
+		/* make sure our calculations won't overflow. most likely
+		   we'll be reading less data, but allow it anyway so caller
+		   doesn't have to deal with any extra checks. */
+		size = SSIZE_T_MAX;
+	}
 
 	if (offset + size > cache->mmap_length &&
 	    offset + size - cache->mmap_length > 1024*1024) {



More information about the dovecot-cvs mailing list