From 52c3a7596e24277229256ee421bc91fb00718806 Mon Sep 17 00:00:00 2001 From: Tim Deegan Date: Wed, 8 Aug 2007 12:26:21 +0100 Subject: [TOOLS] Avoid unaligned accesses in libfsimage FAT16 code Signed-off-by: Kouya Shimura Signed-off-by: KUWAMURA Shin'ya --- tools/libfsimage/fat/fsys_fat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools/libfsimage') diff --git a/tools/libfsimage/fat/fsys_fat.c b/tools/libfsimage/fat/fsys_fat.c index 9d74bdf1a9..a0afb87f49 100644 --- a/tools/libfsimage/fat/fsys_fat.c +++ b/tools/libfsimage/fat/fsys_fat.c @@ -228,15 +228,15 @@ fat_read (fsi_file_t *ffi, char *buf, int len) if (!devread (ffi, sector, 0, FAT_CACHE_SIZE, (char*) FAT_BUF)) return 0; } - next_cluster = * (unsigned long *) (FAT_BUF + (cached_pos >> 1)); + next_cluster = ((__u16 *) (FAT_BUF + (cached_pos >> 1)))[0]; if (FAT_SUPER->fat_size == 3) { if (cached_pos & 1) next_cluster >>= 4; next_cluster &= 0xFFF; } - else if (FAT_SUPER->fat_size == 4) - next_cluster &= 0xFFFF; + else if (FAT_SUPER->fat_size > 4) + next_cluster |= ((__u16 *) (FAT_BUF + (cached_pos >> 1)))[1] << 16; if (next_cluster >= FAT_SUPER->clust_eof_marker) return ret; -- cgit v1.2.3