summaryrefslogtreecommitdiffstats
path: root/libblkid
diff options
context:
space:
mode:
authorKarel Zak2018-04-12 14:21:47 +0200
committerKarel Zak2018-04-12 14:21:47 +0200
commit2b8ac985ba8a6e3aa374bdb5e3cf3268fc765609 (patch)
tree302414919549170e322e00890cb52f2483b37cd5 /libblkid
parentlscpu: Cortex-A12 merged into Cortex-A17 (diff)
downloadkernel-qcow2-util-linux-2b8ac985ba8a6e3aa374bdb5e3cf3268fc765609.tar.gz
kernel-qcow2-util-linux-2b8ac985ba8a6e3aa374bdb5e3cf3268fc765609.tar.xz
kernel-qcow2-util-linux-2b8ac985ba8a6e3aa374bdb5e3cf3268fc765609.zip
libblkid: (hfs) check allocation size
The current prober is based on signature only (two bytes!). It seems pretty fragile. Linux kernel also checks for allocation size in the superblock, let's use it too... it's better than nothing. Reported-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid')
-rw-r--r--libblkid/src/superblocks/hfs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libblkid/src/superblocks/hfs.c b/libblkid/src/superblocks/hfs.c
index 19f14ed0d..7b0117405 100644
--- a/libblkid/src/superblocks/hfs.c
+++ b/libblkid/src/superblocks/hfs.c
@@ -25,6 +25,8 @@ struct hfs_finder_info {
uint8_t id[8];
} __attribute__((packed));
+#define HFS_SECTOR_SIZE 512
+
struct hfs_mdb {
uint8_t signature[2];
uint32_t cr_date;
@@ -153,6 +155,7 @@ static int hfs_set_uuid(blkid_probe pr, unsigned char const *hfs_info, size_t le
static int probe_hfs(blkid_probe pr, const struct blkid_idmag *mag)
{
struct hfs_mdb *hfs;
+ int size;
hfs = blkid_probe_get_sb(pr, mag, struct hfs_mdb);
if (!hfs)
@@ -162,6 +165,12 @@ static int probe_hfs(blkid_probe pr, const struct blkid_idmag *mag)
(memcmp(hfs->embed_sig, "HX", 2) == 0))
return 1; /* Not hfs, but an embedded HFS+ */
+ size = be32_to_cpu(hfs->al_blk_size);
+ if (!size || (size & (HFS_SECTOR_SIZE - 1))) {
+ DBG(LOWPROBE, ul_debug("\tbad allocation size - ignore"));
+ return 1;
+ }
+
hfs_set_uuid(pr, hfs->finder_info.id, sizeof(hfs->finder_info.id));
blkid_probe_set_label(pr, hfs->label, hfs->label_len);