diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-01-30 11:08:21 +0100 |
---|---|---|
committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-02-03 11:10:37 +0100 |
commit | 0be286cd6de995d6249508ebde6cfb8066045d77 (patch) | |
tree | fcfa34c23e7fd070399577e1b775c711104bb874 /fs | |
parent | 4c4006b694c4188a6face1c70bf16d0c5d49a2e9 (diff) | |
download | u-boot-0be286cd6de995d6249508ebde6cfb8066045d77.tar.gz u-boot-0be286cd6de995d6249508ebde6cfb8066045d77.tar.bz2 u-boot-0be286cd6de995d6249508ebde6cfb8066045d77.zip |
fs: fat: must not write directory '.' and '..'
Directories or files called '.' or '..' cannot be created or written to
in any directory. Move the test to normalize_longname() to check this
early.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fat/fat_write.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index a9b9fa5d68..8945649977 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -1259,8 +1259,10 @@ again: static int normalize_longname(char *l_filename, const char *filename) { const char *p, illegal[] = "<>:\"/\\|?*"; + size_t len; - if (strlen(filename) >= VFAT_MAXLEN_BYTES) + len = strlen(filename); + if (!len || len >= VFAT_MAXLEN_BYTES || filename[len - 1] == '.') return -1; for (p = filename; *p; ++p) { @@ -1348,15 +1350,6 @@ int file_fat_write_at(const char *filename, loff_t pos, void *buffer, char shortname[SHORT_NAME_SIZE]; int ndent; - if (itr->is_root) { - /* root dir cannot have "." or ".." */ - if (!strcmp(l_filename, ".") || - !strcmp(l_filename, "..")) { - ret = -EINVAL; - goto exit; - } - } - if (pos) { /* No hole allowed */ ret = -EINVAL; |