diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2006-05-30 15:47:12 +0200 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2006-05-30 15:47:12 +0200 |
commit | 94fa1108eecb92bc595ae6f4927d2aeaea4049e8 (patch) | |
tree | 31c96b536c96f0723fc831a25f3e93f2894f162a /lib/blkid | |
parent | 0ac93a00c98af2f44e5d291788c7ccaa3ed239d3 (diff) | |
download | e2fsprogs-94fa1108eecb92bc595ae6f4927d2aeaea4049e8.tar.gz |
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 <matthias.andree@gmx.de>
Diffstat (limited to 'lib/blkid')
-rw-r--r-- | lib/blkid/probe.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index e7fdc9c1..7beef9de 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); |