diff options
author | Karel Zak | 2010-01-20 23:30:20 +0100 |
---|---|---|
committer | Karel Zak | 2010-01-21 00:20:19 +0100 |
commit | 2b09166ddac2cd671ca28111a25e342304d6223f (patch) | |
tree | 79c5288ceb5b2a9707305eb750e0e534c5b54661 /shlibs/blkid/src/partitions/dos.c | |
parent | blkid: probe for PT, don't probe for FS on small whole-disks (diff) | |
download | kernel-qcow2-util-linux-2b09166ddac2cd671ca28111a25e342304d6223f.tar.gz kernel-qcow2-util-linux-2b09166ddac2cd671ca28111a25e342304d6223f.tar.xz kernel-qcow2-util-linux-2b09166ddac2cd671ca28111a25e342304d6223f.zip |
libblkid: add sanity checks for FAT to DOS PT parser
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/partitions/dos.c')
-rw-r--r-- | shlibs/blkid/src/partitions/dos.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/shlibs/blkid/src/partitions/dos.c b/shlibs/blkid/src/partitions/dos.c index 21728a5ae..ec2ca1ebe 100644 --- a/shlibs/blkid/src/partitions/dos.c +++ b/shlibs/blkid/src/partitions/dos.c @@ -16,6 +16,7 @@ #include "partitions.h" #include "dos.h" #include "aix.h" +#include "fat.h" static const struct dos_subtypes { unsigned char type; @@ -139,18 +140,30 @@ static int probe_dos_pt(blkid_probe pr, const struct blkid_idmag *mag) if (memcmp(data, BLKID_AIX_MAGIC_STRING, BLKID_AIX_MAGIC_STRLEN) == 0) goto nothing; - p0 = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET); - /* * Now that the 55aa signature is present, this is probably * either the boot sector of a FAT filesystem or a DOS-type - * partition table. Reject this in case the boot indicator - * is not 0 or 0x80. + * partition table. */ - for (p = p0, i = 0; i < 4; i++, p++) { + { + struct msdos_super_block *ms = + (struct msdos_super_block *) data; + + if (ms->ms_fats && ms->ms_reserved && + ms->ms_cluster_size && + blkid_fat_valid_media(ms) && + blkid_fat_valid_sectorsize(ms, NULL)) + goto nothing; /* FAT */ + } + + p0 = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET); + + /* + * Reject PT where boot indicator is not 0 or 0x80. + */ + for (p = p0, i = 0; i < 4; i++, p++) if (p->boot_ind != 0 && p->boot_ind != 0x80) goto nothing; - } /* * GPT uses valid MBR |