diff options
author | Jules Maselbas <jmaselbas@kalray.eu> | 2021-04-18 01:34:09 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-05-03 14:44:56 +0200 |
commit | 74946415a5d28e496ab4f49749d3b55707390811 (patch) | |
tree | 646306e3d77216829cff7dc3db15df176e499dd5 /fs | |
parent | 34663cd903ca52a428e2751ca11df4a3471f2e5c (diff) | |
download | barebox-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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fs.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -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) |