Skip to content

Exit Codes and Errors

bisu edited this page Sep 21, 2026 · 1 revision

Exit Codes and Errors

Exit codes

Code Meaning
0 Success
1 Usage error (unknown/invalid flags — reported by clap)
2 File-system error (missing file, permission denied, not a regular file)
3 Malformed, truncated, unsupported binary, or file over the 512 MiB limit

Error model

AppError (error.rs) has four variants, each mapped to an exit code and to UI guidance:

Variant Code Examples
Io 2 No such file or directory, permission denied
InvalidFileType 2 Symlink, directory, FIFO, device node
FileTooLarge 3 File exceeds the 512 MiB inspection limit
Parse 3 Any ParseError from the ELF decoder

The CLI prints binary-inspector: <error> on stderr. The GUI renders a failure card with a category title and remediation hint (AppError::guidance()), e.g. "BinaryInspector requires regular files. Symlinks, directories, FIFOs, and special devices are not supported."

ParseError variants

Variant Meaning
FileTooShort Fewer bytes than the smallest valid ELF header
InvalidMagic Missing the \x7fELF magic
UnsupportedVersion ELF identifier version is not 1
UnsupportedClass Neither ELF32 nor ELF64
UnsupportedEndianness Neither little- nor big-endian
OutOfBounds A table or field points outside the file
IntegerOverflow Checked arithmetic refused an offset/size computation
InvalidHeader A header field violates ELF structural constraints
InvalidStringTable A required string is unterminated or over the 4 KiB per-string cap
LimitExceeded A table exceeded its safety cap — see Safety-Model
Malformed Any other specification violation

Panics

Parsing is panic-free by design: all offset arithmetic is checked and every table/string has a cap. The fuzz target treats any panic as a bug — see Fuzzing-and-Testing.

Clone this wiki locally