From 94fa1108eecb92bc595ae6f4927d2aeaea4049e8 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Tue, 30 May 2006 15:47:12 +0200 Subject: [PATCH] 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 --- lib/blkid/probe.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index e7fdc9c..7beef9d 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); -- 1.8.3.1