diff options
Diffstat (limited to 'firmware/common/rbpaths.c')
-rw-r--r-- | firmware/common/rbpaths.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/firmware/common/rbpaths.c b/firmware/common/rbpaths.c index 7632b70306..8cf92fab4a 100644 --- a/firmware/common/rbpaths.c +++ b/firmware/common/rbpaths.c | |||
@@ -341,10 +341,14 @@ DIR* app_opendir(const char *_name) | |||
341 | return NULL; | 341 | return NULL; |
342 | 342 | ||
343 | struct __dir *this = (struct __dir*)buf; | 343 | struct __dir *this = (struct __dir*)buf; |
344 | /* definitely fits due to strlen() */ | 344 | /* carefully remove any trailing slash from the input, so that |
345 | strcpy(this->path, name); | 345 | * hash/path matching in readdir() works properly */ |
346 | 346 | while (name[name_len-1] == '/') | |
347 | this->dir = opendir(name); | 347 | name_len -= 1; |
348 | /* strcpy cannot be used because of trailing slashes */ | ||
349 | memcpy(this->path, name, name_len); | ||
350 | this->path[name_len] = 0; | ||
351 | this->dir = opendir(this->path); | ||
348 | 352 | ||
349 | if (!this->dir) | 353 | if (!this->dir) |
350 | { | 354 | { |