* [PATCH 1/2] fs: fix error path in __canonicalize_path()
@ 2018-04-16 12:22 Ulrich Ölmann
2018-04-16 12:22 ` [PATCH 2/2] fs: remove shortcut in canonicalizing filenames Ulrich Ölmann
0 siblings, 1 reply; 2+ messages in thread
From: Ulrich Ölmann @ 2018-04-16 12:22 UTC (permalink / raw)
To: Barebox List
Report failure in resolving links to the caller and only clean up memory then.
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
fs/fs.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index 5135112c8b81..7c818eca024f 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -202,8 +202,11 @@ static char *__canonicalize_path(const char *_pathname, int level)
continue;
ret = readlink(outpath, link, PATH_MAX - 1);
- if (ret < 0)
+ if (ret < 0) {
+ free(outpath);
+ outpath = ERR_PTR(ret);
goto out;
+ }
if (link[0] == '/') {
free(outpath);
@@ -218,14 +221,15 @@ static char *__canonicalize_path(const char *_pathname, int level)
if (IS_ERR(outpath))
goto out;
}
-out:
- free(freep);
if (!*outpath) {
free(outpath);
outpath = xstrdup("/");
}
+out:
+ free(freep);
+
return outpath;
}
--
2.16.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] fs: remove shortcut in canonicalizing filenames
2018-04-16 12:22 [PATCH 1/2] fs: fix error path in __canonicalize_path() Ulrich Ölmann
@ 2018-04-16 12:22 ` Ulrich Ölmann
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Ölmann @ 2018-04-16 12:22 UTC (permalink / raw)
To: Barebox List
Only individually getting the file status for every part of the path tells us if
a symbolic link is involved or not. If this is the case the later call to
readlink will check if the filesystem supports symbolic links or not.
Hence this reverts commit d79a81736f64 ("fs: Don't bother filesystems without
link support with additional stat() calls").
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
fs/fs.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index 7c818eca024f..b2da0a62a29d 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -144,7 +144,6 @@ char *normalise_path(const char *pathname)
EXPORT_SYMBOL(normalise_path);
static int __lstat(const char *filename, struct stat *s);
-static struct fs_device_d *get_fsdevice_by_path(const char *path);
static char *__canonicalize_path(const char *_pathname, int level)
{
@@ -167,7 +166,6 @@ static char *__canonicalize_path(const char *_pathname, int level)
char *p = strsep(&path, "/");
char *tmp;
char link[PATH_MAX] = {};
- struct fs_device_d *fsdev;
if (!p)
break;
@@ -186,14 +184,6 @@ static char *__canonicalize_path(const char *_pathname, int level)
free(outpath);
outpath = tmp;
- /*
- * Don't bother filesystems without link support
- * with an additional stat() call.
- */
- fsdev = get_fsdevice_by_path(outpath);
- if (!fsdev || !fsdev->driver->readlink)
- continue;
-
ret = __lstat(outpath, &s);
if (ret)
goto out;
--
2.16.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-16 12:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16 12:22 [PATCH 1/2] fs: fix error path in __canonicalize_path() Ulrich Ölmann
2018-04-16 12:22 ` [PATCH 2/2] fs: remove shortcut in canonicalizing filenames Ulrich Ölmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox