mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
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>
This commit is contained in:
parent
4c4006b694
commit
0be286cd6d
1 changed files with 3 additions and 10 deletions
|
@ -1259,8 +1259,10 @@ again:
|
||||||
static int normalize_longname(char *l_filename, const char *filename)
|
static int normalize_longname(char *l_filename, const char *filename)
|
||||||
{
|
{
|
||||||
const char *p, illegal[] = "<>:\"/\\|?*";
|
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;
|
return -1;
|
||||||
|
|
||||||
for (p = filename; *p; ++p) {
|
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];
|
char shortname[SHORT_NAME_SIZE];
|
||||||
int ndent;
|
int ndent;
|
||||||
|
|
||||||
if (itr->is_root) {
|
|
||||||
/* root dir cannot have "." or ".." */
|
|
||||||
if (!strcmp(l_filename, ".") ||
|
|
||||||
!strcmp(l_filename, "..")) {
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos) {
|
if (pos) {
|
||||||
/* No hole allowed */
|
/* No hole allowed */
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
|
Loading…
Reference in a new issue