tftp: extend multi-block read results in place - #5110
Merged
Conversation
AI-Assisted: yes (GPT-5.6-Cyber)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5110 +/- ##
==========================================
+ Coverage 80.59% 80.63% +0.03%
==========================================
Files 390 390
Lines 96892 96895 +3
==========================================
+ Hits 78094 78130 +36
+ Misses 18798 18765 -33
🚀 New features to boost your workflow:
|
gpotter2
reviewed
Aug 27, 2026
Addresses review feedback on secdev#5110: rather than switching self.res between bytes and bytearray, initialise it as a bytearray and convert once when the automaton returns. Removes the isinstance branching; the accumulate line goes back to a plain +=. AI-Assisted: yes (GPT-5.6-Sol)
gpotter2
approved these changes
Aug 27, 2026
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.
TFTP_readis Scapy's client automaton for downloading a file block by block. Each accepted remoteDATA block reaches immutable
self.res += recvdatscapy/layers/tftp.py:196-234,which recopies every prior response before waiting for the next block.
From 4,000 to 16,000 full blocks, median processing grew from 82.41 ms to 1,308.05 ms, with a 2.13
exponent and an 11.5% noise floor. Patched times were 21.39 ms to 87.75 ms, with a 1.04 exponent and
a 1.7% noise floor.
This change retains the single-block bytes path, extends one
bytearrayafter a second block, andconverts it back to bytes at the final transition. The focused regression failed on the unmodified
revision and passed with the patch.