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>
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) {
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;