]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: ext - avoid undefined shift
authorMilan Broz <gmazyland@gmail.com>
Thu, 13 Oct 2022 12:59:15 +0000 (14:59 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 17 Oct 2022 07:12:37 +0000 (09:12 +0200)
Ext filesystems probe can use undefined shift if s_log_block_size
is a bogus value. Avoid this by limiting shift size.

Reproducer found with OSS-Fuzz (issue 52370) running over
cryptsetup project (blkid is used in header init).

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/ext.c

index e6d620167ada2bd0e92de1c66238ef9fff935b82..1c799429e5cf41b32fc39fd271f6f06ab2a3160d 100644 (file)
@@ -189,8 +189,9 @@ static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es)
                le32_to_cpu(es->s_rev_level),
                le16_to_cpu(es->s_minor_rev_level));
 
-       uint32_t block_size = 1024U << le32_to_cpu(es->s_log_block_size);
+       uint32_t block_size = 0;
        if (le32_to_cpu(es->s_log_block_size) < 32){
+               block_size = 1024U << le32_to_cpu(es->s_log_block_size);
                blkid_probe_set_fsblocksize(pr, block_size);
                blkid_probe_set_block_size(pr, block_size);
        }