diff options
Diffstat (limited to 'firmware/common/file.c')
-rw-r--r-- | firmware/common/file.c | 14 |
1 files changed, 11 insertions, 3 deletions
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) | |||
117 | return -4; | 117 | return -4; |
118 | } | 118 | } |
119 | 119 | ||
120 | if(name[0] == 0) { | ||
121 | DEBUGF("Empty file name\n"); | ||
122 | errno = EINVAL; | ||
123 | file->busy = false; | ||
124 | closedir(dir); | ||
125 | return -5; | ||
126 | } | ||
127 | |||
120 | /* scan dir for name */ | 128 | /* scan dir for name */ |
121 | while ((entry = readdir(dir))) { | 129 | while ((entry = readdir(dir))) { |
122 | if ( !strcasecmp(name, entry->d_name) ) { | 130 | if ( !strcasecmp(name, entry->d_name) ) { |
@@ -140,7 +148,7 @@ int open(const char* pathname, int flags) | |||
140 | errno = EIO; | 148 | errno = EIO; |
141 | file->busy = false; | 149 | file->busy = false; |
142 | closedir(dir); | 150 | closedir(dir); |
143 | return rc * 10 - 5; | 151 | return rc * 10 - 6; |
144 | } | 152 | } |
145 | file->size = 0; | 153 | file->size = 0; |
146 | file->attr = 0; | 154 | file->attr = 0; |
@@ -150,7 +158,7 @@ int open(const char* pathname, int flags) | |||
150 | errno = ENOENT; | 158 | errno = ENOENT; |
151 | file->busy = false; | 159 | file->busy = false; |
152 | closedir(dir); | 160 | closedir(dir); |
153 | return -6; | 161 | return -7; |
154 | } | 162 | } |
155 | } | 163 | } |
156 | closedir(dir); | 164 | closedir(dir); |
@@ -161,7 +169,7 @@ int open(const char* pathname, int flags) | |||
161 | if (file->write && (flags & O_APPEND)) { | 169 | if (file->write && (flags & O_APPEND)) { |
162 | rc = lseek(fd,0,SEEK_END); | 170 | rc = lseek(fd,0,SEEK_END); |
163 | if (rc < 0 ) | 171 | if (rc < 0 ) |
164 | return rc * 10 - 7; | 172 | return rc * 10 - 8; |
165 | } | 173 | } |
166 | 174 | ||
167 | return fd; | 175 | return fd; |