aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libfsimage
diff options
context:
space:
mode:
authorTim Deegan <Tim.Deegan@xensource.com>2007-08-08 12:26:21 +0100
committerTim Deegan <Tim.Deegan@xensource.com>2007-08-08 12:26:21 +0100
commit52c3a7596e24277229256ee421bc91fb00718806 (patch)
tree3f03900f9bbaf5bc9f457bd11754d65f1da47619 /tools/libfsimage
parentc0efd4c9393885bfa80d1511d152aaed4202c3be (diff)
downloadxen-52c3a7596e24277229256ee421bc91fb00718806.tar.gz
xen-52c3a7596e24277229256ee421bc91fb00718806.tar.bz2
xen-52c3a7596e24277229256ee421bc91fb00718806.zip
[TOOLS] Avoid unaligned accesses in libfsimage FAT16 code
Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com> Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com>
Diffstat (limited to 'tools/libfsimage')
-rw-r--r--tools/libfsimage/fat/fsys_fat.c6
1 files changed, 3 insertions, 3 deletions
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;