summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-02-11 14:37:16 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-02-11 14:37:16 +0000
commit05f1fc465402f235a775e529a7f5b732632da554 (patch)
tree22e1fc2f6ce11965f022d401b4b4aa35ba5edb60 /firmware
parentb646d4f278017b4b3797ab0976239bd64df8b43e (diff)
Empty file/dir names are now rejected by open() and mkdir()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4303 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/dir.c12
-rw-r--r--firmware/common/file.c14
2 files changed, 20 insertions, 6 deletions
diff --git a/firmware/common/dir.c b/firmware/common/dir.c
index e33bb7fc8f..c3965c2418 100644
--- a/firmware/common/dir.c
+++ b/firmware/common/dir.c
@@ -127,9 +127,9 @@ int mkdir(char *name, int mode)
int rc;
(void)mode;
-
+
if ( name[0] != '/' ) {
- DEBUGF("Only absolute paths supported right now\n");
+ DEBUGF("mkdir: Only absolute paths supported right now\n");
return -1;
}
@@ -155,13 +155,19 @@ int mkdir(char *name, int mode)
return -2;
}
+ if(basename[0] == 0) {
+ DEBUGF("mkdir: Empty dir name\n");
+ errno = EINVAL;
+ return -3;
+ }
+
/* Now check if the name already exists */
while ((entry = readdir(dir))) {
if ( !strcasecmp(basename, entry->d_name) ) {
DEBUGF("mkdir error: file exists\n");
errno = EEXIST;
closedir(dir);
- return - 3;
+ return - 4;
}
}
diff --git a/firmware/common/file.c b/firmware/common/file.c
index f81038fa77..3a91bda876 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -117,6 +117,14 @@ int open(const char* pathname, int flags)
return -4;
}
+ if(name[0] == 0) {
+ DEBUGF("Empty file name\n");
+ errno = EINVAL;
+ file->busy = false;
+ closedir(dir);
+ return -5;
+ }
+
/* scan dir for name */
while ((entry = readdir(dir))) {
if ( !strcasecmp(name, entry->d_name) ) {
@@ -140,7 +148,7 @@ int open(const char* pathname, int flags)
errno = EIO;
file->busy = false;
closedir(dir);
- return rc * 10 - 5;
+ return rc * 10 - 6;
}
file->size = 0;
file->attr = 0;
@@ -150,7 +158,7 @@ int open(const char* pathname, int flags)
errno = ENOENT;
file->busy = false;
closedir(dir);
- return -6;
+ return -7;
}
}
closedir(dir);
@@ -161,7 +169,7 @@ int open(const char* pathname, int flags)
if (file->write && (flags & O_APPEND)) {
rc = lseek(fd,0,SEEK_END);
if (rc < 0 )
- return rc * 10 - 7;
+ return rc * 10 - 8;
}
return fd;