From: Matthias Andree Date: Tue, 30 May 2006 13:47:12 +0000 (+0200) Subject: Fix SIGBUS through unaligned access to FAT superblocks. X-Git-Tag: E2FSPROGS-1_40-WIP-1114~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94fa1108eecb92bc595ae6f4927d2aeaea4049e8;p=thirdparty%2Fe2fsprogs.git Fix SIGBUS through unaligned access to FAT superblocks. SPARCs do not like unaligned halfword access and throw SIGBUS. Read data "manually" instead. Tested on Solaris 8/SPARC with gcc 2.95.3. Signed-off-by: Matthias Andree --- diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index e7fdc9c14..7beef9de6 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -253,7 +253,7 @@ static int probe_fat(struct blkid_probe *probe, struct msdos_super_block *ms = (struct msdos_super_block *) buf; struct vfat_dir_entry *dir; char serno[10]; - const unsigned char *label = 0, *vol_label = 0; + const unsigned char *label = 0, *vol_label = 0, *tmp; unsigned char *vol_serno; int label_len = 0, maxloop = 100; __u16 sector_size, dir_entries, reserved; @@ -261,14 +261,17 @@ static int probe_fat(struct blkid_probe *probe, __u32 buf_size, start_data_sect, next, root_start, root_dir_entries; /* sector size check */ - sector_size = blkid_le16(*((__u16 *) &ms->ms_sector_size)); + tmp = &ms->ms_sector_size; + sector_size = tmp[0] + tmp[1] << 8; if (sector_size != 0x200 && sector_size != 0x400 && sector_size != 0x800 && sector_size != 0x1000) return 1; - dir_entries = blkid_le16(*((__u16 *) &ms->ms_dir_entries)); + tmp = &ms->ms_dir_entries; + dir_entries = tmp[0] + tmp[1] << 8; reserved = blkid_le16(ms->ms_reserved); - sect_count = blkid_le16(*((__u16 *) &ms->ms_sectors)); + tmp = &ms->ms_sectors; + sect_count = tmp[0] + tmp[1] << 8; if (sect_count == 0) sect_count = blkid_le32(ms->ms_total_sect);