aboutsummaryrefslogtreecommitdiff
path: root/fs/fat/fat_write.c
diff options
context:
space:
mode:
authorTom Rini2018-07-30 16:02:29 -0400
committerTom Rini2018-07-30 16:02:29 -0400
commit406fd7e207d3593f150079514a371dccdc651ce7 (patch)
tree005f94b428abc454efd05f56364ee052cb16ac39 /fs/fat/fat_write.c
parent3a8c8bffd767abb350010f3892c0029c54cef725 (diff)
parent0b8a88ab6aa24de0ef2bf1e8109409f71e770a8e (diff)
Merge tag 'signed-efi-next' of git://github.com/agraf/u-boot
Patch queue for efi - 2018-07-25 Highlights this time: - Many small fixes to improve spec compatibility (found by SCT) - Almost enough to run with sandbox target - GetTime() improvements - Enable EFI_LOADER and HYP entry on ARMv7 with NONSEC=y
Diffstat (limited to 'fs/fat/fat_write.c')
-rw-r--r--fs/fat/fat_write.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 3b77557b3ed..27e0ff66966 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -909,9 +909,11 @@ static int do_fat_write(const char *filename, void *buffer, loff_t size,
volume_info volinfo;
fsdata datablock;
fsdata *mydata = &datablock;
- int cursect;
+ int cursect, i;
int ret = -1, name_len;
char l_filename[VFAT_MAXLEN_BYTES];
+ char bad[2] = " ";
+ const char illegal[] = "<>:\"/\\|?*";
*actwrite = size;
dir_curclust = 0;
@@ -971,6 +973,18 @@ static int do_fat_write(const char *filename, void *buffer, loff_t size,
}
dentptr = (dir_entry *) do_fat_read_at_block;
+ /* Strip leading (back-)slashes */
+ while ISDIRDELIM(*filename)
+ ++filename;
+ /* Check that the filename is valid */
+ for (i = 0; i < strlen(illegal); ++i) {
+ *bad = illegal[i];
+ if (strstr(filename, bad)) {
+ printf("FAT: illegal filename (%s)\n", filename);
+ return -1;
+ }
+ }
+
name_len = strlen(filename);
if (name_len >= VFAT_MAXLEN_BYTES)
name_len = VFAT_MAXLEN_BYTES - 1;