Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Broken elf header incorrectly identified as missing file
- X-seq: zsh-workers 54373
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Nathan <nathan.titirangi@xxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: Broken elf header incorrectly identified as missing file
- Date: Fri, 17 Apr 2026 10:00:02 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Ak0lVhIxyiwD1h1uILoME5U+PxOVKUMpmiNMN62/Fec=; fh=L2nnjOJ9RjAn075W9a+RDUgv81qKoRKbcS32LLjvMms=; b=GLseqqAIVafkgEd6XSKSYnrg9xlrKxnUmt6fZHs/YUXIzIzTMhXxQziTDudnOGGnbZ C9EN5lbpVz3zEr8vhT1ffGGEkPi7BqrzL4bi0komnrYAYMkC7shO4YmBH9YP9QyeSr04 DJ5bUJ1mR/EbBYcsKaTGbSil6LBK7VI20pSJQ0EP1M47uj80w4zAsuPHX7/9i+AEINU0 atkfFcQujwZrkxaQ6tq4+dCbh+B/HfI0Wql45BfoXxg4nTauAJnEjgd9x4VL6P85FZbF GXZ8eGwvcZKdsMNkC7ZHqNk1udddx9byzUFvan7I9HT+3mYP0MwkhZuq/5mxzscThWNi 5e3w==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1776445215; cv=none; d=google.com; s=arc-20240605; b=YV5ZyJjcVlgG+xWBPOi8sC5JHKiPkg79k8PntieuP1aer5R/7rq1jY92fHzfjVZkmi coXd9m3euGhRwPTBbYFjpr82I3DEnu1x2/jbG+8y8biwoanLYfujb0Cc5RN1fM8U7sm2 bMiQicrW0u1IBH/2wA8+FbZt4OYrYVEy+qWvRUDiWH5EBIEJpq2/w0t7Q+FOKAg0u5+a ghVjuQ2nlDvx/m4uy6IpP1fw/p14vnYU7qdiIAOR4S3WQaMmIQu1JXy0J0IA0dElt8sy 9gntw/hHwUjYlZZy2tfnMwEHy+wgeYLNf28K9vghmFMt0j/81qlrBeFTaTGwzvIZEnNu aUvw==
- Archived-at: <https://zsh.org/workers/54373>
- In-reply-to: <CAE3bff1FTL_XEeAXEWgv+1bLKFvc3Yd4YjVZRG-V3yY3iZ44EQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAE3bff1FTL_XEeAXEWgv+1bLKFvc3Yd4YjVZRG-V3yY3iZ44EQ@mail.gmail.com>
On Thu, Apr 16, 2026 at 7:47 PM Nathan <nathan.titirangi@xxxxxxxxx> wrote:
>
> 1. Create a malformed elf binary by deleting everything past part way through the file (a broken binary that triggers the bug is attached)
[...]
> 4. Observe that the file is incorrectly identified as not existing, when the actual issue is a broken elf header
Firstly, "command not found" does not mean "missing file". If you are
actually getting a "no such file" error, it probably means the shell
is attempting to read the file as command input and is reporting that
what it thinks is a #! introduction is not followed by a reference to
any existing file, although that would be odd and I'd expect a "bad
interpreter" error or similar.
Secondly, this is an OS-specific problem (see Oliver's reply). On MacOs:
% dd if=/bin/cat of=$HOME/bin/broken bs=1024 count=1
1+0 records in
1+0 records out
1024 bytes transferred in 0.000589 secs (1738540 bytes/sec)
% chmod +x ~/bin/broken
% broken
zsh: malformed Mach-o file: broken
Thirdly, trying the above on Ubuntu:
% dd if=/bin/cat of=$HOME/bin/broken bs=1024 count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 4.4878e-05 s, 22.8 MB/s
% chmod +x ~/bin/broken
% broken
zsh: segmentation fault broken
I can't get anything but a segmentation fault, I never get "not found"
or "no such file".
% file =broken
/home/schaefer/bin/broken: ELF 64-bit LSB shared object, x86-64,
version 1 (SYSV), dynamically linked, interpreter
/lib64/ld-linux-x86-64.so.2, missing section headers at 39320
Finally, if this is important to you for some reason, try adding to .zshrc:
command_not_found_handler() {
local search=( ${^path}/$1(N) )
[[ -n $search ]] && file $search
return 127
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author