This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 8ac04c4f2bb binfmt: Fail with ENOENT for an empty file name.
8ac04c4f2bb is described below

commit 8ac04c4f2bb9c275e451c0ad27ac990fc7c5a989
Author: Marco Casaroli <[email protected]>
AuthorDate: Fri Oct 23 23:15:48 2026 +0200

    binfmt: Fail with ENOENT for an empty file name.
    
    load_module() searched PATH for a file name without a '/'.  An empty
    name has no '/' either, so exec(), posix_spawn() and posix_spawnp() of
    "" went to the PATH search, and envpath_next() stopped the system at
    DEBUGASSERT(relpath[0] != '\0').  Any user program can do this.  POSIX
    specifies ENOENT for an empty path or file name.
    
    Return -ENOENT for an empty name before the PATH search.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 binfmt/binfmt_loadmodule.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/binfmt/binfmt_loadmodule.c b/binfmt/binfmt_loadmodule.c
index b02fa9ed8d6..99480cef5f2 100644
--- a/binfmt/binfmt_loadmodule.c
+++ b/binfmt/binfmt_loadmodule.c
@@ -196,6 +196,15 @@ int load_module(FAR struct binary_s *bin, FAR const char 
*filename,
           return ret;
         }
 
+      /* An empty file name names no file (POSIX: ENOENT).  It is not a
+       * bare file name to search for in PATH.
+       */
+
+      if (filename[0] == '\0')
+        {
+          return -ENOENT;
+        }
+
       /* A bare file name (no '/') is searched for in PATH.  Any other path
        * is used as given: an absolute path, or a path relative to the
        * current working directory, as POSIX specifies for a name that

Reply via email to