Mailing List Archive

[xen-unstable] [TOOLS] Avoid unaligned accesses in libfsimage FAT16 code
# HG changeset patch
# User Tim Deegan <Tim.Deegan@xensource.com>
# Date 1186572381 -3600
# Node ID 123ad31e9c3bb98685fea54a2e4d9f4cf57ac44f
# Parent 7953164cebb6dfbbee08d06c91f424b63d87ed71
[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>
---
tools/libfsimage/fat/fsys_fat.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff -r 7953164cebb6 -r 123ad31e9c3b tools/libfsimage/fat/fsys_fat.c
--- a/tools/libfsimage/fat/fsys_fat.c Tue Aug 07 09:07:29 2007 +0100
+++ b/tools/libfsimage/fat/fsys_fat.c Wed Aug 08 12:26:21 2007 +0100
@@ -228,15 +228,15 @@ fat_read (fsi_file_t *ffi, char *buf, in
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;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog