345715
From 604b607d8ac91eb8afc0b6e3d917d5c073096103 Mon Sep 17 00:00:00 2001
345715
From: Phillip Lougher <phillip@squashfs.org.uk>
345715
Date: Wed, 11 Jun 2014 04:51:37 +0100
345715
Subject: mksquashfs: ensure value does not overflow a signed int in -mem
345715
 option
345715
345715
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
345715
345715
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
345715
index 5370ecf..9676dc8 100644
345715
--- a/squashfs-tools/mksquashfs.c
345715
+++ b/squashfs-tools/mksquashfs.c
345715
@@ -5193,7 +5193,16 @@ print_compressor_options:
345715
 					 argv[0]);
345715
 				exit(1);
345715
 			}
345715
-			/* convert from bytes to Mbytes */
345715
+
345715
+			/*
345715
+			 * convert from bytes to Mbytes, ensuring the value
345715
+			 * does not overflow a signed int
345715
+			 */
345715
+			if(number >= (1LL << 51)) {
345715
+				ERROR("%s: -mem invalid mem size\n", argv[0]);
345715
+				exit(1);
345715
+			}
345715
+
345715
 			total_mem = number / 1048576;
345715
 			if(total_mem < (SQUASHFS_LOWMEM / SQUASHFS_TAKE)) {
345715
 				ERROR("%s: -mem should be %d Mbytes or "
345715
-- 
345715
cgit v0.10.1
345715