From 97f7083ba8e0079764fffe304dff81701e8e503d Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sun, 19 Feb 2023 09:14:47 +0100 Subject: [PATCH] src/apfs_common.c: avoid integer overflow when checking block count. --- src/apfs_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apfs_common.c b/src/apfs_common.c index ee3d25cc..57ab9c31 100644 --- a/src/apfs_common.c +++ b/src/apfs_common.c @@ -74,7 +74,7 @@ int test_APFS(const nx_superblock_t *sb, const partition_t *partition) { if(le32(sb->nx_magic)!=0x4253584e) return 1; - if(le32(sb->nx_xp_desc_blocks) + le32(sb->nx_xp_data_blocks) > le64(sb->nx_block_count)) + if((uint64_t)le32(sb->nx_xp_desc_blocks) + le32(sb->nx_xp_data_blocks) > le64(sb->nx_block_count)) return 2; if(le32(sb->nx_block_size) < NX_MINIMUM_BLOCK_SIZE || le32(sb->nx_block_size) > NX_MAXIMUM_BLOCK_SIZE)