diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-02-10 15:59:46 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-02-10 15:59:46 -0800 |
commit | e8d0e6fb18aae44474e864d8040d5ed44ff6acab (patch) | |
tree | 547115848f342060950112d85b83706ef12fd800 /libinstaller | |
parent | 5396e250a679c368b3dd353c730358d6c54960c8 (diff) | |
parent | 2dafb8402ed666b37f96f6e1579a99b8a8c85452 (diff) | |
download | syslinux-e8d0e6fb18aae44474e864d8040d5ed44ff6acab.tar.gz syslinux-e8d0e6fb18aae44474e864d8040d5ed44ff6acab.tar.xz syslinux-e8d0e6fb18aae44474e864d8040d5ed44ff6acab.zip |
Merge branch 'fsc' into pathbased
Resolved Conflicts:
core/fs/ext2/ext2.c
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'libinstaller')
-rw-r--r-- | libinstaller/syslxint.h | 1 | ||||
-rw-r--r-- | libinstaller/syslxmod.c | 35 |
2 files changed, 22 insertions, 14 deletions
diff --git a/libinstaller/syslxint.h b/libinstaller/syslxint.h index 7f8d3041..2276bfed 100644 --- a/libinstaller/syslxint.h +++ b/libinstaller/syslxint.h @@ -129,6 +129,7 @@ struct boot_sector { uint32_t RootClus; uint16_t FSInfo; uint16_t BkBootSec; + uint8_t Reserved0[12]; uint8_t DriveNumber; uint8_t Reserved1; uint8_t BootSignature; diff --git a/libinstaller/syslxmod.c b/libinstaller/syslxmod.c index 42160375..0285bb41 100644 --- a/libinstaller/syslxmod.c +++ b/libinstaller/syslxmod.c @@ -52,19 +52,20 @@ const char *syslinux_check_bootsect(const void *bs) /* Must be 0xF0 or 0xF8..0xFF */ if (get_8(§buf->bsMedia) != 0xF0 && get_8(§buf->bsMedia) < 0xF8) - goto invalid; + return "invalid media signature (not a FAT filesystem?)"; sectorsize = get_16(§buf->bsBytesPerSec); - if (sectorsize == SECTOR_SIZE) ; /* ok */ + if (sectorsize == SECTOR_SIZE) + ; /* ok */ else if (sectorsize >= 512 && sectorsize <= 4096 && (sectorsize & (sectorsize - 1)) == 0) return "unsupported sectors size"; else - goto invalid; + return "impossible sector size"; clustersize = get_8(§buf->bsSecPerClust); if (clustersize == 0 || (clustersize & (clustersize - 1))) - goto invalid; /* Must be nonzero and a power of 2 */ + return "impossible cluster size"; sectors = get_16(§buf->bsSectors); sectors = sectors ? sectors : get_32(§buf->bsHugeSectors); @@ -79,8 +80,11 @@ const char *syslinux_check_bootsect(const void *bs) rootdirents = get_16(§buf->bsRootDirEnts); dsectors -= (rootdirents + sectorsize / 32 - 1) / sectorsize; - if (dsectors < 0 || fatsectors == 0) - goto invalid; + if (dsectors < 0) + return "negative number of data sectors"; + + if (fatsectors == 0) + return "zero FAT sectors"; clusters = dsectors / clustersize; @@ -88,7 +92,7 @@ const char *syslinux_check_bootsect(const void *bs) /* FAT12 or FAT16 */ if (!get_16(§buf->bsFATsecs)) - goto invalid; + return "zero FAT sectors (FAT12/16)"; if (get_8(§buf->bs16.BootSignature) == 0x29) { if (!memcmp(§buf->bs16.FileSysType, "FAT12 ", 8)) { @@ -97,6 +101,8 @@ const char *syslinux_check_bootsect(const void *bs) } else if (!memcmp(§buf->bs16.FileSysType, "FAT16 ", 8)) { if (clusters < 0xFF5) return "less than 4084 clusters but claims FAT16"; + } else if (!memcmp(§buf->bs16.FileSysType, "FAT32 ", 8)) { + return "less than 65525 clusters but claims FAT32"; } else if (memcmp(§buf->bs16.FileSysType, "FAT ", 8)) { static char fserr[] = "filesystem type \"????????\" not supported"; @@ -105,19 +111,20 @@ const char *syslinux_check_bootsect(const void *bs) } } } else if (clusters < 0x0FFFFFF5) { - /* FAT32 */ - /* Moving the FileSysType and BootSignature was a lovely stroke of M$ idiocy */ + /* + * FAT32... + * + * Moving the FileSysType and BootSignature was a lovely stroke + * of M$ idiocy... + */ if (get_8(§buf->bs32.BootSignature) != 0x29 || memcmp(§buf->bs32.FileSysType, "FAT32 ", 8)) - goto invalid; + return "missing FAT32 signature"; } else { - goto invalid; + return "impossibly large number of clusters"; } return NULL; - -invalid: - return "this doesn't look like a valid FAT filesystem"; } /* |