Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Broken elf header incorrectly identified as missing file



Nathan wrote:
> On zsh 5.9 (x86_64-ubuntu-linux-gnu)
>
> To reproduce:
> 1. Create a malformed elf binary by deleting everything past part way through
> the file (a broken binary that triggers the bug is attached)
> 2. Make the binary executable
> 3. Attempt to run the binary with ./b.out
> 4. Observe that the file is incorrectly identified as not existing, when the
> actual issue is a broken elf header

It is not the job of the shell to dig in to malformed binaries. We pass
it on to the operating system and system loader and error handling is
their job.

> Bash returns the correct error message, but several other shells return the
> same wrong error.

Probably because bash does go poking around in ELF binaries. This was
proposed (and rejected) also for zsh, see:

zsh-workers/34909 or https://www.zsh.org/mla/workers/2015/msg00833.html

I've not examined the attached binary as such. If there are ways to get
better errors just from the OS APIs then let us know. Not all systems
zsh runs on use ELF.

Oliver




Messages sorted by: Reverse Date, Date, Thread, Author