summaryrefslogtreecommitdiffstats
path: root/src/fat.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-10-20 12:27:45 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2013-10-20 12:27:45 +0200
commit9398e8ab2cea8b6104bd960d18ba5f443ca710e8 (patch)
tree5bb86166218eb37f59bf67df18a226eb254d5bf4 /src/fat.c
parenta971b56765f155593220732c6d50e7d271c800d8 (diff)
FAT12 media descriptor should be 0xf0. FAT32 Drive number should be 0 or between 0x80 and 0x87.
Diffstat (limited to 'src/fat.c')
-rw-r--r--src/fat.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/fat.c b/src/fat.c
index 477e094..0450544 100644
--- a/src/fat.c
+++ b/src/fat.c
@@ -475,17 +475,6 @@ int test_FAT(disk_t *disk_car, const struct fat_boot_sector *fat_header, partiti
log_error("check_FAT: Bad number %u of FAT\n", fat_header->fats);
return 1;
}
- if(fat_header->media!=0xF0 && fat_header->media<0xF8)
- { /* Legal values are 0xF0, 0xF8-0xFF */
- screen_buffer_add("check_FAT: Bad media descriptor (0x%2x!=0xf8)\n",fat_header->media);
- log_error("check_FAT: Bad media descriptor (0x%2x!=0xf8)\n",fat_header->media);
- return 1;
- }
- if(fat_header->media!=0xF8)
- { /* the only value I have ever seen is 0xF8 */
- screen_buffer_add("check_FAT: Unusual media descriptor (0x%2x!=0xf8)\n",fat_header->media);
- log_warning("check_FAT: Unusual media descriptor (0x%2x!=0xf8)\n",fat_header->media);
- }
if(fat_sector_size(fat_header)!=disk_car->sector_size)
{
screen_buffer_add("check_FAT: number of bytes per sector mismatches %u (FAT) != %u (HD)\n",
@@ -505,6 +494,12 @@ int test_FAT(disk_t *disk_car, const struct fat_boot_sector *fat_header, partiti
{
log_info("number of cluster = %lu\n",no_of_cluster);
}
+ if(fat_header->media!=0xF0 && fat_header->media<0xF8)
+ { /* Legal values are 0xF0, 0xF8-0xFF */
+ screen_buffer_add("check_FAT: Bad media descriptor (0x%02x!=0xf8)\n",fat_header->media);
+ log_error("check_FAT: Bad media descriptor (0x%02x!=0xf8)\n",fat_header->media);
+ return 1;
+ }
if(no_of_cluster<4085)
{
if(verbose>0)
@@ -544,6 +539,11 @@ int test_FAT(disk_t *disk_car, const struct fat_boot_sector *fat_header, partiti
screen_buffer_add("Should be marked as FAT12\n");
log_warning("Should be marked as FAT12\n");
}
+ if(fat_header->media!=0xF0)
+ {
+ screen_buffer_add("check_FAT: Unusual media descriptor (0x%02x!=0xf0)\n", fat_header->media);
+ log_warning("check_FAT: Unusual media descriptor (0x%02x!=0xf0)\n", fat_header->media);
+ }
}
else if(no_of_cluster<65525)
{
@@ -579,6 +579,11 @@ int test_FAT(disk_t *disk_car, const struct fat_boot_sector *fat_header, partiti
screen_buffer_add("Should be marked as FAT16\n");
log_warning("Should be marked as FAT16\n");
}
+ if(fat_header->media!=0xF8)
+ { /* the only value I have ever seen is 0xF8 */
+ screen_buffer_add("check_FAT: Unusual media descriptor (0x%02x!=0xf8)\n", fat_header->media);
+ log_warning("check_FAT: Unusual media descriptor (0x%02x!=0xf8)\n", fat_header->media);
+ }
}
else
{
@@ -620,6 +625,16 @@ int test_FAT(disk_t *disk_car, const struct fat_boot_sector *fat_header, partiti
screen_buffer_add("Should be marked as FAT32\n");
log_warning("Should be marked as FAT32\n");
}
+ if(fat_header->media!=0xF8)
+ { /* the only value I have ever seen is 0xF8 */
+ screen_buffer_add("check_FAT: Unusual media descriptor (0x%02x!=0xf8)\n", fat_header->media);
+ log_warning("check_FAT: Unusual media descriptor (0x%02x!=0xf8)\n", fat_header->media);
+ }
+ if(fat_header->BS_DrvNum!=0 && (fat_header->BS_DrvNum<0x80 || fat_header->BS_DrvNum>0x87))
+ {
+ screen_buffer_add("Warning: Unusual drive number (0x%02x!=0x80)\n", fat_header->BS_DrvNum);
+ log_warning("Warning: Unusual drive number (0x%02x!=0x80)\n", fat_header->BS_DrvNum);
+ }
}
if(partition->part_size>0)
{