changeset 2916:d1780331ad04 HEAD

Don't crash if trying to read more than INT_MAX bytes. Just silently allow it.
author Timo Sirainen <tss@iki.fi>
date Mon, 29 Nov 2004 14:21:24 +0200
parents 25bc79e67271
children e657c7874962
files src/lib/file-cache.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/file-cache.c	Mon Nov 29 04:30:14 2004 +0200
+++ b/src/lib/file-cache.c	Mon Nov 29 14:21:24 2004 +0200
@@ -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) {