Subj : sexyz: SIGFPE (divide by zero) when the ZMODEM transmit window is smal To : GitLab issue in main/sbbs From : Rob Swindell Date : Fri Jul 24 2026 11:14:53 open https://gitlab.synchro.net/main/sbbs/-/issues/1197 `sexyz` dies with **SIGFPE** (integer divide-by-zero) as soon as it starts sending, whenever the ZMODEM transmit window is smaller than **4x the block size**. ### Reproduction ``` $ dd if=/dev/urandom of=test.bin bs=1M count=8 $ sexyz -8 -w8192 sz test.bin # window 8K, block 8K ``` The sender handshakes (ZRQINIT/ZRINIT) and then dies before transferring any file data; the process exit status is signal 8 (SIGFPE). Anything that reports the raw wait status shows `-8`. Roughly 3 KB reaches the wire, all handshake. Also crashes: `-8 -w16384`, `-8 -w32767`, `-2 -w4096`, and the equivalents set via `MaxWindowSize` in `sexyz.ini`. Does **not** crash when the window is at least 4 blocks, e.g. `-8 -w32768`. ### Cause `src/sbbs3/zmodem.c`, in `zmodem_send_from()`: ```c tx_type = (subpkts_sent % (zm->max_window_size / zm->block_size / 4)) == 0 ? ZCRCQ : ZCRCG; ``` With `max_window_size == block_size == 8192` the divisor is `8192 / 8192 / 4` = `1 / 4` = **0**, so the `%` is a division by zero. The intent is "request an ACK every quarter-window"; a window narrower than four blocks has no valid quarter-window interval. ### Fix Clamp the interval to a minimum of 1, so a window smaller than four blocks requests an ACK on every subpacket. ### Scope `zmodem.c` is shared with SyncTERM, but **SyncTERM never sets `max_window_size`** (it leaves it 0, which short-circuits the branch), so this is not reachable there. The exposure is `sexyz` only, via `-w` or the `MaxWindowSize` ini key. ### Related, not fixed here With the divide-by-zero guarded, a window exactly equal to the block size (`-8 -w8192`) no longer crashes but is pathologically slow -- roughly one subpacket per second, each iteration logging a one-second receive timeout followed by `Transmit-Window management: 8192 >= 8192`. It completes, but it cannot pipeline. That is a separate issue. --- *Reported and fixed by Claude (Anthropic), working with Rob Swindell.* * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705) .