You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Static binary crashes at startup when the command ends in an option-like argument (bash -i) #1575
The static release binary crashes at startup (SIGSEGV) when the command's last argument looks like a ttyd option that takes a value, for example bash -i.
calc_command_start() in src/server.c copies argv into a buffer of exactly argc pointers, with no NULL terminator, and runs getopt_long over the copy. The command's trailing -i is parsed as ttyd's -i <interface> with its value missing. musl's getopt then advances optind to argc + 1 and permutes the array up to index argc, writing one pointer past the end of the heap buffer. musl's allocator detects the corruption at free(argv_copy) and traps (hlt, reported as SIGSEGV with si_code=SI_KERNEL).
On a real argv, slot argc is the NULL terminator, so the same permutation is harmless there. glibc builds may not show the problem; I only tested the musl static release binary.
Two core dumps from real launches show the out-of-bounds slot directly:
ttyd -p 7682 -i 127.0.0.1 -W -o bash --noprofile -i (argc = 10): the copy has room for 10 pointers; slot 9 holds NULL and slot 10, one past the end, holds "bash".
A 20-argument launch ending in bash --noprofile --rcfile <file> -i: slot 20 holds a pointer to <file>.
Activity
fix(server): correct musl argv-copy overflow and option permutation