Skip to content

clamp packet length in zyfer_receive to bound a_lastcode#29

Open
arib06 wants to merge 1 commit into
ntp-project:stablefrom
arib06:zyfer-recv-length-clamp
Open

clamp packet length in zyfer_receive to bound a_lastcode#29
arib06 wants to merge 1 commit into
ntp-project:stablefrom
arib06:zyfer-recv-length-clamp

Conversation

@arib06

@arib06 arib06 commented Jul 5, 2026

Copy link
Copy Markdown

clamp recv_length in zyfer_receive before appending to a_lastcode, otherwise a short leading '!' line that seeds a small lencode followed by a packet longer than the buffer's remaining space overruns the 128-byte a_lastcode (recv_length reaches up to RX_BUFF_SIZE), matching the length clamp already used in jupiter_receive.

@hart-NTP

Copy link
Copy Markdown
Collaborator

Thanks for the report, @arib06. Please consider filing a report at https://bugs.ntp.org./ This repo is currently out of date on GitHub, but I checked and this shortcoming persists in the latest code.

@arib06

arib06 commented Jul 20, 2026

Copy link
Copy Markdown
Author

Will do, I'll file this at bugs.ntp.org with the details.

For the record, I confirmed it with a standalone ASAN harness that mirrors the else-branch append: seed lencode=1 with a short '!' line, then feed a 220-byte packet. Unpatched that gives a heap-buffer-overflow WRITE of size 220 at the memcpy past the 128-byte a_lastcode; with the clamp it stops at lencode=127 and runs clean. Valid Zyfer input is a 29-byte timecode so it never reaches the clamp.

Happy to leave this PR open or close it once the bug report is in, whichever you prefer.

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