casaroli opened a new pull request, #20597: URL: https://github.com/apache/nuttx/pull/20597
## Summary `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 a shell runs such a file itself only on `ENOEXEC`. A shell printed "No data available" instead of running the script. This PR returns `ENOEXEC` when the file ends before the ELF header, as for any other file that is not an ELF file. The first commit fixes the old nxstyle errors in `elf_init.c`, with no code change. ## Impact `exec()` of a short non-ELF file fails with `ENOEXEC` instead of `ENODATA`. ## Testing The run-time tests ran on a local branch that has this change and other pending changes on top of master; the builds are of this branch alone. qemu-armv8a, kernel build, QEMU 11 with HVF: a one-line script without `#!` (`echo "no-shebang file run by $0"`), started from an interactive shell as `./plain.sh`, prints its line. Before, the shell printed "No data available". Builds with `-Wno-cpp -Werror`: `qemu-armv8a:knsh`, `mps2-an500:nsh`. `tools/checkpatch.sh -c -u -m -g` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
