From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: Dennis Menschel <menschel-d@posteo.de>
Subject: [PATCH 1/2] fs: avoid pathes with '//' in __canonicalize_path()
Date: Tue, 5 Sep 2017 10:00:20 +0200 [thread overview]
Message-ID: <20170905080021.22248-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170905080021.22248-1-s.hauer@pengutronix.de>
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>
---
fs/fs.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index c9226f9ba6..a5efdd1423 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -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;
}
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2017-09-05 8:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-05 8:00 Fix tftpd-hpa support Sascha Hauer
2017-09-05 8:00 ` Sascha Hauer [this message]
2017-09-05 8:00 ` [PATCH 2/2] fs: Don't bother filesystems without link support with additional stat() calls Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170905080021.22248-2-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=menschel-d@posteo.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox