]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: bcachefs: use uint64_t for structure length
authorThomas Weißschuh <thomas@t-8ch.de>
Wed, 25 Jan 2023 04:27:20 +0000 (04:27 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Wed, 25 Jan 2023 15:38:16 +0000 (15:38 +0000)
The value of "u64s" can overflow when multiplied by 8.
Use a larger type to avoid this.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libblkid/src/superblocks/bcache.c

index b66ed8b196a35e70f4c6aff70a4c23d0cf4f8030..aba636a361cdbb095ed04ad43c936dd0c2760907 100644 (file)
@@ -113,7 +113,7 @@ struct bcachefs_super_block {
 /* tag value for members field */
 #define BCACHEFS_SB_FIELD_TYPE_MEMBERS 1
 
-#define BYTES(f) ((le32_to_cpu((f)->u64s) * 8))
+#define BYTES(f) ((((uint64_t) le32_to_cpu((f)->u64s)) * 8))
 
 static int bcache_verify_checksum(blkid_probe pr, const struct blkid_idmag *mag,
                const struct bcache_super_block *bcs)
@@ -246,8 +246,7 @@ static int probe_bcachefs(blkid_probe pr, const struct blkid_idmag *mag)
 {
        struct bcachefs_super_block *bcs;
        unsigned char *sb, *sb_end;
-       unsigned long sb_size;
-       uint64_t blocksize;
+       uint64_t sb_size, blocksize;
 
        bcs = blkid_probe_get_sb(pr, mag, struct bcachefs_super_block);
        if (!bcs)