From: Theodore Ts'o Date: Tue, 10 Jul 2018 22:12:54 +0000 (-0400) Subject: blkid: avoid FPE crash when probing a HFS+ superblock with a zero blocksize X-Git-Tag: v1.44.4~35 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=e96393142ccd1da25ac1e2c9cebd7f20326f36c5;p=tools%2Fe2fsprogs.git blkid: avoid FPE crash when probing a HFS+ superblock with a zero blocksize This problem was reported by Adam Buchbinder. Signed-off-by: Theodore Ts'o --- diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index 865d9aa..283ee0a 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -1184,6 +1184,8 @@ static int probe_hfs(struct blkid_probe *probe __BLKID_ATTR((unused)), } +#define HFSPLUS_SECTOR_SIZE 512 + static int probe_hfsplus(struct blkid_probe *probe, struct blkid_magic *id, unsigned char *buf) @@ -1247,6 +1249,9 @@ static int probe_hfsplus(struct blkid_probe *probe, } blocksize = blkid_be32(hfsplus->blocksize); + if (blocksize < HFSPLUS_SECTOR_SIZE) + return 1; + memcpy(extents, hfsplus->cat_file.extents, sizeof(extents)); cat_block = blkid_be32(extents[0].start_block);