ia64/xen-unstable

changeset 15730:123ad31e9c3b

[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>
author Tim Deegan <Tim.Deegan@xensource.com>
date Wed Aug 08 12:26:21 2007 +0100 (2007-08-08)
parents 7953164cebb6
children 35337d5c83f9
files tools/libfsimage/fat/fsys_fat.c
line diff
     1.1 --- a/tools/libfsimage/fat/fsys_fat.c	Tue Aug 07 09:07:29 2007 +0100
     1.2 +++ b/tools/libfsimage/fat/fsys_fat.c	Wed Aug 08 12:26:21 2007 +0100
     1.3 @@ -228,15 +228,15 @@ fat_read (fsi_file_t *ffi, char *buf, in
     1.4  	      if (!devread (ffi, sector, 0, FAT_CACHE_SIZE, (char*) FAT_BUF))
     1.5  		return 0;
     1.6  	    }
     1.7 -	  next_cluster = * (unsigned long *) (FAT_BUF + (cached_pos >> 1));
     1.8 +	  next_cluster = ((__u16 *) (FAT_BUF + (cached_pos >> 1)))[0];
     1.9  	  if (FAT_SUPER->fat_size == 3)
    1.10  	    {
    1.11  	      if (cached_pos & 1)
    1.12  		next_cluster >>= 4;
    1.13  	      next_cluster &= 0xFFF;
    1.14  	    }
    1.15 -	  else if (FAT_SUPER->fat_size == 4)
    1.16 -	    next_cluster &= 0xFFFF;
    1.17 +	  else if (FAT_SUPER->fat_size > 4)
    1.18 +	    next_cluster |= ((__u16 *) (FAT_BUF + (cached_pos >> 1)))[1] << 16;
    1.19  	  
    1.20  	  if (next_cluster >= FAT_SUPER->clust_eof_marker)
    1.21  	    return ret;