application: fix opendir() for "/" directory.

"/" couldn't be opened. This regression was introduced by 731072d. Trailing
slash should not be stripped for the root directory.

Change-Id: Idd2d9b1f33e7be789bcf432e586e6715eb4152f4
This commit is contained in:
Thomas Martitz 2014-02-26 00:24:51 +01:00
parent 191bd3da93
commit 6b01da8bed

View file

@ -343,7 +343,7 @@ DIR* app_opendir(const char *_name)
struct __dir *this = (struct __dir*)buf;
/* carefully remove any trailing slash from the input, so that
* hash/path matching in readdir() works properly */
while (name[name_len-1] == '/')
while (name[name_len-1] == '/' && name_len > 1)
name_len -= 1;
/* strcpy cannot be used because of trailing slashes */
memcpy(this->path, name, name_len);