Repository navigation
fix(corekit): skip a record by reading when the stream only claims to seek (#2108) - #2118
Merged
Merged
Conversation
… seek (#2108) advance() trusted seekable(), so a Windows pipe (seekable() True, seek a no-op) handed to Frame(file) or PCAPNG(file) directly was 'skipped' without moving. advance() uses it; extraction.py imports it from there.
Owner
Author
|
GOOD TO GO at
|
Owner
Author
|
Ready to merge at
This closes #2108. |
Contributor
|
Coverage: 91.54% (unit tier, Python 3.15,
Per-file detail: the |
5 tasks done
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.
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix— bug fixesDescription of your pull request and other information
Closes #2108.
advance()inpcapkit/corekit/io.pyskips the rest of a record. It chose seek or read withisinstance(file, SeekableReader) or not file.seekable(). On Windows a pipe claimsseekable()and itsseekdoes nothing (CPython gh-86768), so the skip left the stream where it was.Frame.__post_init__andPCAPNGstore the caller's stream as given, soFrame(pipe, …)andPCAPNG(pipe, …)bypass the wrapping fix(foundation): treat only a regular file's seekable() as trustworthy (#2097) #2104 added toExtractor. The engines only read the Extractor's wrapped_ifile._can_seek()moves verbatim fromextraction.pytoio.py, whereadvance()uses it.extraction.pyonly changes its import.test_io_advance_lying_pipe_2108_unitruns over a realos.pipethat claims to seek. It skips 10,000 octets on a raw and on a buffered pipe and expectsb'next record'next. Without the fix both subtests readAAAA…. A second case pins that a regular file and aBytesIOstill seek.mainwith fix(corekit): let Windows reopen SeekableReader's buffer file (#2098) #2105 and fix(foundation): close the input when the Extractor constructor raises (#2100) #2106 merged. The rebase conflicted only inio.py's import block.