simpleqt opened a new pull request, #424: URL: https://github.com/apache/commons-net/pull/424
`TFTPRequestPacket.newDatagram(DatagramPacket, byte[])` serializes a request into a reusable buffer, but it set the datagram length to `fileLength + modeLength + 3`, without the option extensions. `TFTP.bufferedSend()` sends through that path with its long-lived `sendBuffer`, 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 the `setLength` call in the buffered path, and writes the terminating NUL explicitly instead of relying on the buffer already containing zero. ## Test `TFTPRequestPacketTest.testNewDatagramBufferIncludesOptions` parses 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 by `newDatagram()`. - with the source change reverted: `mvn -B -o -ntp -Dtest=TFTPRequestPacketTest test` -> 3 run, 1 failure, `expected: <30> but was: <17>` - with the change: same command -> 3 run, 0 failures; `mvn -B -o -ntp -Dtest='TFTP*Test' test` -> 33 run, 0 failures The commit carries an `Assisted-By:` trailer and a `src/changes/changes.xml` action. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
