]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: jfs - avoid undefined shift
authorMilan Broz <gmazyland@gmail.com>
Sun, 4 Jun 2023 17:15:55 +0000 (19:15 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 5 Jun 2023 10:08:25 +0000 (12:08 +0200)
Fix previous commit 04a0717b0b0faa1a8078dc6fad05183b8bada395
to avoid undefined shift if value is exactly 32.

  libblkid/src/superblocks/jfs.c:46:39: runtime error:
  shift exponent 32 is too large for 32-bit type 'unsigned int'

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

Signed-off-by: Milan Broz <gmazyland@gmail.com>
libblkid/src/superblocks/jfs.c

index 1b545c7d5077bae892fff1b7df542535df033314..7b75ecb6b57520210ac544c534125781781df123 100644 (file)
@@ -41,7 +41,7 @@ static int probe_jfs(blkid_probe pr, const struct blkid_idmag *mag)
        js = blkid_probe_get_sb(pr, mag, struct jfs_super_block);
        if (!js)
                return errno ? -errno : 1;
-       if (le16_to_cpu(js->js_l2bsize) > 32 || le16_to_cpu(js->js_l2pbsize) > 32)
+       if (le16_to_cpu(js->js_l2bsize) > 31 || le16_to_cpu(js->js_l2pbsize) > 31)
                return 1;
        if (le32_to_cpu(js->js_bsize) != (1U << le16_to_cpu(js->js_l2bsize)))
                return 1;