getname() should return an error for an empty path. While at it, change
getname() to return an error pointer.

Signed-off-by: Sascha Hauer <[email protected]>
---
 fs/fs.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 6de5a3b59e..09fccf9c28 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1866,14 +1866,17 @@ static struct filename *getname(const char *filename)
 {
        struct filename *result;
 
+       if (!*filename)
+               return ERR_PTR(-ENOENT);
+
        result = malloc(sizeof(*result));
        if (!result)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        result->name = strdup(filename);
        if (!result->name) {
                free(result);
-               return NULL;
+               return ERR_PTR(-ENOMEM);
        }
 
        result->refcnt = 1;
-- 
2.29.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to