From 74946415a5d28e496ab4f49749d3b55707390811 Mon Sep 17 00:00:00 2001 From: Jules Maselbas Date: Sun, 18 Apr 2021 01:34:09 +0200 Subject: 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 Signed-off-by: Jules Maselbas Link: https://lore.barebox.org/20210417233409.637-1-jmaselbas@kalray.eu Signed-off-by: Sascha Hauer --- fs/fs.c | 2 ++ 1 file changed, 2 insertions(+) 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) -- cgit v1.2.3