Re: Broken elf header incorrectly identified as missing file

Mikael Magnusson <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <CAHYJk3S_TQJ0arCtdB7MYifC5ouLv3qoLVfprEGjz_6j_ehkpA@mail.gmail.com>
On Fri, Apr 17, 2026 at 2:22 PM Oliver Kiddle <[email protected]> wrote:
>
> 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.

And if the file is not readable, this won't work anyway, so even the
corner case has a corner case.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.