Repository navigation
Conversation
TFTPRequestPacket.newDatagram(DatagramPacket, byte[]) computed the datagram length without the encoded option extensions, so a request parsed with options and forwarded through TFTP.bufferedSend() lost its options. Count the option extensions once and write their trailing NUL terminator explicitly. Assisted-By: DeepSeek Harness (deepseek-v41-flash)
simpleqt
force-pushed
the
fix/tftp-buffered-request-options
branch
from
November 16, 2026 11:25
0951b2f to
b6f9b70
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TFTPRequestPacket.newDatagram(DatagramPacket, byte[])serializes a request into a reusable buffer, but it set the datagram length tofileLength + modeLength + 3, without the option extensions.TFTP.bufferedSend()sends through that path with its long-livedsendBuffer, so a read/write request that carries options (blksize,timeout,tsize, ...) was sent truncated: the options were written into the buffer but the datagram length stopped before them.The options were only correct when the caller happened to use
newDatagram()(which allocates exactly the right size) or when the reused buffer still had zero bytes after the mode string, which is why the bug was invisible until the buffer was reused.The fix counts the option extensions once (
getOptionsLength()), includes them in thesetLengthcall in the buffered path, and writes the terminating NUL explicitly instead of relying on the buffer already containing zero.Test
TFTPRequestPacketTest.testNewDatagramBufferIncludesOptionsparses a read request with options, fills a reused buffer with a non-zero sentinel, serializes into it through the buffered overload and asserts both the datagram length and the buffer bytes match the packet built bynewDatagram().mvn -B -o -ntp -Dtest=TFTPRequestPacketTest test-> 3 run, 1 failure,expected: <30> but was: <17>mvn -B -o -ntp -Dtest='TFTP*Test' test-> 33 run, 0 failuresThe commit carries an
Assisted-By:trailer.