]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: befs: fix possible too large shift
authorMilan Broz <gmazyland@gmail.com>
Fri, 31 Jul 2026 14:27:45 +0000 (16:27 +0200)
committerMilan Broz <gmazyland@gmail.com>
Fri, 31 Jul 2026 14:32:55 +0000 (16:32 +0200)
The existing guard needs to be evaluated as uint64_t otherwise
it wraps around.

Found by OSS-Fuzz by cryptsetup project fuzzers (issue 507641687).

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

index e8005ffe628768256df082151f46ddb0361bbfcf..a7a9d30a964fadb538745faceb75a6df7912ce11 100644 (file)
@@ -519,7 +519,7 @@ static int probe_befs(blkid_probe pr, const struct blkid_idmag *mag)
 
        /* get_block_run() shifts uint64 left by ag_shift + block_shift,
         * so the combined value must stay below 64 to avoid UB */
-       if (FS32_TO_CPU(bs->ag_shift, fs_le) + block_shift >= 64)
+       if ((uint64_t)FS32_TO_CPU(bs->ag_shift, fs_le) + block_shift >= 64)
                return BLKID_PROBE_NONE;
 
        ret = get_uuid(pr, bs, &volume_id, fs_le);