[PATCH 07/10] mkfs.cramfs: fix unsigned integer overflow [AddressSanitizer]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



disk-utils/mkfs.cramfs.c:622:20: runtime error: unsigned integer
overflow: 64 - 512 cannot be represented in type 'unsigned long'

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 disk-utils/mkfs.cramfs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index bae68ec..d9a9153 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -619,7 +619,10 @@ do_compress(char *base, unsigned int offset, unsigned char const *name,
 	/* TODO: Arguably, original_size in these 2 lines should be
 	   st_blocks * 512.  But if you say that, then perhaps
 	   administrative data should also be included in both. */
-	change = new_size - original_size;
+	if (new_size <= original_size)
+		change = new_size - original_size;
+	else
+		change = new_size;
 	if (verbose)
 		printf(_("%6.2f%% (%+ld bytes)\t%s\n"),
 		       (change * 100) / (double) original_size, change, name);
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux