From e96393142ccd1da25ac1e2c9cebd7f20326f36c5 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 10 Jul 2018 18:12:54 -0400 Subject: [PATCH] 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 --- lib/blkid/probe.c | 5 +++++ 1 file changed, 5 insertions(+) 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); -- 1.8.3.1