You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2026/10/12 13:03:36 UTC

(nuttx) branch master updated (ca0394bda43 -> d51cfb39746)

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

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


    from ca0394bda43 fs/inode: Keep the rest of the path when a soft link in a path is followed.
     new 266b341d612 libs/libc/elf: Fix the nxstyle errors in elf_init.c.
     new d51cfb39746 libs/libc/elf: Return ENOEXEC for a file shorter than an ELF header.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 libs/libc/elf/elf_init.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)


(nuttx) 01/02: libs/libc/elf: Fix the nxstyle errors in elf_init.c.

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 266b341d61286898c3bb5edc01c7699b8e8dbf21
Author: Marco Casaroli <ma...@gmail.com>
AuthorDate: Sun Oct 11 11:43:26 2026 +0200

    libs/libc/elf: Fix the nxstyle errors in elf_init.c.
    
    Add the blank lines after declarations.  No code change.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <ma...@gmail.com>
---
 libs/libc/elf/elf_init.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libs/libc/elf/elf_init.c b/libs/libc/elf/elf_init.c
index 1845b9c14fd..8493c367dd1 100644
--- a/libs/libc/elf/elf_init.c
+++ b/libs/libc/elf/elf_init.c
@@ -66,6 +66,7 @@ static inline int libelf_fileinfo(FAR struct mod_loadinfo_s *loadinfo)
   if (ret < 0)
     {
       int errval = _NX_GETERRNO(ret);
+
       berr("ERROR: Failed to stat file: %d\n", errval);
       return -errval;
     }
@@ -113,6 +114,7 @@ int libelf_initialize(FAR const char *filename,
   if (loadinfo->filfd < 0)
     {
       int errval = _NX_GETERRNO(loadinfo->filfd);
+
       berr("ERROR: Failed to open ELF binary %s: %d\n", filename, errval);
       return -errval;
     }


(nuttx) 02/02: libs/libc/elf: Return ENOEXEC for a file shorter than an ELF header.

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d51cfb39746a1106a0e9b34f9b4779fb07f46511
Author: Marco Casaroli <ma...@gmail.com>
AuthorDate: Sun Oct 11 11:43:26 2026 +0200

    libs/libc/elf: Return ENOEXEC for a file shorter than an ELF header.
    
    exec() of a file that is shorter than an ELF header, for example a
    short shell script without "#!", failed with ENODATA: the read of the
    header reached the end of the file.  POSIX says that exec() fails with
    ENOEXEC when the file has an unrecognized format, and shells run such a
    file themselves only on ENOEXEC: a shell printed "No data available"
    instead of running the script.
    
    Return ENOEXEC when the file ends before the ELF header, as for any
    other file that is not an ELF file.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <ma...@gmail.com>
---
 libs/libc/elf/elf_init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libs/libc/elf/elf_init.c b/libs/libc/elf/elf_init.c
index 8493c367dd1..cbef6e1ba5a 100644
--- a/libs/libc/elf/elf_init.c
+++ b/libs/libc/elf/elf_init.c
@@ -134,8 +134,10 @@ int libelf_initialize(FAR const char *filename,
                     sizeof(Elf_Ehdr), 0);
   if (ret < 0)
     {
+      /* A file that is shorter than an ELF header is not an ELF file */
+
       berr("ERROR: Failed to read ELF header: %d\n", ret);
-      return ret;
+      return ret == -ENODATA ? -ENOEXEC : ret;
     }
 
   libelf_dumpbuffer("ELF header", (FAR const uint8_t *)&loadinfo->ehdr,