Skip to content

Fix silent data corruptoin from strlen() on binary packet data - #560

Merged
davidrg merged 1 commit into
davidrg:masterfrom
jgoerzen:jgoerzen/strlen-bugfix
Aug 8, 2026
Merged

Fix silent data corruptoin from strlen() on binary packet data#560
davidrg merged 1 commit into
davidrg:masterfrom
jgoerzen:jgoerzen/strlen-bugfix

Conversation

@jgoerzen

@jgoerzen jgoerzen commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This is an import of
OpenKermit/ckermit@b58e033

Original description follows:

When a data packet arrives out of order and gets stashed for later, replaying it once the window catches up recalculated its size with strlen(). That breaks when a packet contains a NULL.

Each truncated packet still carries a valid checksum for its own wrong length, so nothing flags an error. The transfer reports success with an incomplete or corrupted file.

rpack() already computes the correct length when it first parses and validates a packet. The fix stores that in r_pkt[].pk_len (mirroring s_pkt[].pk_len on the send side) and uses it instead of recomputing from the data on replay.

The underlying bug has been present since this code was introduced in C-Kermit 5A(188) in 1992, 34 years ago! Commit
OpenKermit/ckermit@a213649

This is an import of
OpenKermit/ckermit@b58e033

Original description follows:

When a data packet arrives out of order and gets stashed for later,
replaying it once the window catches up recalculated its size
with strlen().  That breaks when a packet contains a NULL.

Each truncated packet still carries a valid checksum for its own
wrong length, so nothing flags an error.  The transfer reports
success with an incomplete or corrupted file.

rpack() already computes the correct length when it first parses and
validates a packet.  The fix stores that in r_pkt[].pk_len (mirroring
s_pkt[].pk_len on the send side) and uses it instead of recomputing
from the data on replay.

The underlying bug has been present since this code was introduced in
C-Kermit 5A(188) in 1992, 34 years ago!  Commit
OpenKermit/ckermit@a213649
@davidrg
davidrg merged commit 85ef4ba into davidrg:master Aug 8, 2026
32 checks passed
@jgoerzen
jgoerzen deleted the jgoerzen/strlen-bugfix branch August 8, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants