diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-09-05 09:38:59 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-09-06 13:55:11 +0200 |
commit | eed363f4479795a0d005dfd40d11a1936e62ab40 (patch) | |
tree | 39610051dc0fb03fedc0981b3093fca5ffff2d08 | |
parent | d01954ef973a883fe8d51c610c1f89dc5bbc9f1e (diff) | |
download | barebox-eed363f4479795a0d005dfd40d11a1936e62ab40.tar.gz barebox-eed363f4479795a0d005dfd40d11a1936e62ab40.tar.xz |
fs: avoid pathes with '//' in __canonicalize_path()
In __canonicalize_path pathes beginning with '//' can occur. This
is normally not a problem since normalize_path() will clean this
up, but it means we cannot call get_fsdevice_by_path() on these
pathes in this function, as needed in the next patch.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | fs/fs.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -158,8 +158,8 @@ static char *__canonicalize_path(const char *_pathname, int level) path = freep = xstrdup(_pathname); - if (*path == '/') - outpath = xstrdup("/"); + if (*path == '/' || !strcmp(cwd, "/")) + outpath = xstrdup(""); else outpath = __canonicalize_path(cwd, level + 1); @@ -212,6 +212,11 @@ static char *__canonicalize_path(const char *_pathname, int level) out: free(freep); + if (!*outpath) { + free(outpath); + outpath = xstrdup("/"); + } + return outpath; } |