summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJules Maselbas <jmaselbas@kalray.eu>2021-04-18 01:34:09 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-05-03 14:44:56 +0200
commit74946415a5d28e496ab4f49749d3b55707390811 (patch)
tree646306e3d77216829cff7dc3db15df176e499dd5
parent34663cd903ca52a428e2751ca11df4a3471f2e5c (diff)
downloadbarebox-74946415a5d28e496ab4f49749d3b55707390811.tar.gz
barebox-74946415a5d28e496ab4f49749d3b55707390811.tar.xz
fs: Fix link_path_walk to return -ENOENT on empty path
link_path_walk was returning 0 when passed with an empty path, this lead calling code to assume that the struct nameidata nd is valid and thus has a `last` field populated, which is not. In the end causing a runtime crash. This issue can easily be reproduced by running the command: cat "" Reported-by: Neeraj Pal <neerajpal09@gmail.com> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Link: https://lore.barebox.org/20210417233409.637-1-jmaselbas@kalray.eu Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--fs/fs.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/fs.c b/fs/fs.c
index a023324913..6de5a3b59e 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1928,6 +1928,8 @@ static int link_path_walk(const char *name, struct nameidata *nd)
int err;
char separator = '/';
+ if (!*name)
+ return -ENOENT;
while (*name=='/')
name++;
if (!*name)