From e93046d1b1fb3daa309e6c56781047631c74963c Mon Sep 17 00:00:00 2001 From: zhengyu16 Date: Wed, 24 Sep 2025 13:21:09 +0800 Subject: [PATCH] fs/inode: return ENOENT if pathname is empty in inode_search An empty pathname does not name any inode. Return -ENOENT early in inode_search() when the path is an empty string, instead of continuing into the search logic with a zero-length path. Signed-off-by: zhengyu16 --- fs/inode/fs_inodesearch.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/inode/fs_inodesearch.c b/fs/inode/fs_inodesearch.c index 8badfe9a374..460a5554dbf 100644 --- a/fs/inode/fs_inodesearch.c +++ b/fs/inode/fs_inodesearch.c @@ -477,6 +477,11 @@ int inode_search(FAR struct inode_search_s *desc) DEBUGASSERT(desc != NULL && desc->path != NULL); + if (*desc->path == '\0') + { + return -ENOENT; + } + /* Convert the relative path to the absolute path */ if (*desc->path != '/')