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 <tytso@mit.edu>
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 @@
}
+#define HFSPLUS_SECTOR_SIZE 512
+
static int probe_hfsplus(struct blkid_probe *probe,
struct blkid_magic *id,
unsigned char *buf)
@@ -1247,6 +1249,9 @@
}
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);