summaryrefslogtreecommitdiffstats
path: root/src/fat.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2007-12-06 00:34:10 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2007-12-06 00:34:10 +0100
commit56e807748e6e8ee7e924834fc2516d4e63dbca3c (patch)
tree355967b1cf856e15aa8a8d42c76d71f256b91bc0 /src/fat.c
parentf51aa191c2be32b989b4ddb5fee31b8bfd75edf5 (diff)
Better handle FAT filenames
Rename filenames while copying under Dos and Windows
Diffstat (limited to 'src/fat.c')
-rw-r--r--src/fat.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/fat.c b/src/fat.c
index db793bb..6f302f9 100644
--- a/src/fat.c
+++ b/src/fat.c
@@ -317,7 +317,7 @@ static int set_FAT_info(disk_t *disk_car, const struct fat_boot_sector *fat_head
if(buffer[38]==0x29) /* BS_BootSig */
{
fat_set_part_name(partition,((const unsigned char*)fat_header)+FAT1X_PART_NAME,11);
- if(check_volume_name(partition->fsname,11))
+ if(check_VFAT_volume_name(partition->fsname, 11))
partition->fsname[0]='\0';
}
break;
@@ -326,7 +326,7 @@ static int set_FAT_info(disk_t *disk_car, const struct fat_boot_sector *fat_head
if(buffer[38]==0x29) /* BS_BootSig */
{
fat_set_part_name(partition,((const unsigned char*)fat_header)+FAT1X_PART_NAME,11);
- if(check_volume_name(partition->fsname,11))
+ if(check_VFAT_volume_name(partition->fsname, 11))
partition->fsname[0]='\0';
}
break;
@@ -929,7 +929,7 @@ int fat32_set_part_name(disk_t *disk_car, partition_t *partition, const struct f
{
/* dump_ncurses(&buffer[i*0x20],0x20); */
fat_set_part_name(partition,&buffer[i*0x20],11);
- if(check_volume_name(partition->fsname,11))
+ if(check_VFAT_volume_name(partition->fsname, 11))
partition->fsname[0]='\0';
}
if(buffer[i*0x20]==0)
@@ -944,7 +944,7 @@ int fat32_set_part_name(disk_t *disk_car, partition_t *partition, const struct f
{
log_info("set_FAT_info: name from BS used\n");
fat_set_part_name(partition,((const unsigned char*)fat_header)+FAT32_PART_NAME,11);
- if(check_volume_name(partition->fsname,11))
+ if(check_VFAT_volume_name(partition->fsname, 11))
partition->fsname[0]='\0';
}
return 0;
@@ -1207,3 +1207,26 @@ int fat32_free_info(disk_t *disk_car,const partition_t *partition, const unsigne
return 0;
}
+int check_VFAT_volume_name(const char *name, const unsigned int max_size)
+{
+ unsigned int i;
+ for(i=0;name[i]!='\0' && i<max_size;i++)
+ {
+ if(name[i] < 0x20)
+ return 1;
+ switch(name[i])
+ {
+ case '<':
+ case '>':
+ case ':':
+ case '"':
+ case '/':
+ case '\\':
+ case '|':
+ case '?':
+ case '*':
+ return 1;
+ }
+ }
+ return 0; /* Ok */
+}