-
Notifications
You must be signed in to change notification settings - Fork 68
Add readahead buffer to C decoder #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I think a changelog entry should be added for this. |
agronholm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one change request.
|
On further inspection I'm also introducing another bug here in the case where decode_from_bytes is called on tag data during decoding, as described in the documentation: Lines 99 to 112 in 403c2ce
Currently I believe this will overwrite the readahead buffer, losing bytes. Will need another look. |
|
Is it good for another round now? |
|
Ugh, a little bit of shotgun coding there. Since that failed twice I'd like to review it again more thoroughly tomorrow before adding a changelog entry. |
- configurable readahead buffer (default 4KB) to reduce Python read() calls - add read_size parameter to CBORDecoder.__init__ - per-instance buffers for thread-safety
|
Please don't force push changes. It makes it hard for me to track changes you've made. |
|
Ok, now I've convinced myself I understand what the issue was and that it's properly fixed. I ended up refactoring a bit, there was a lot of back and forth in the commits so I thought it made most sense to squash it. The diff should be smaller and hopefully easier to review now. |
|
Now I'll have to re-read everything, as I have no clue what the problem was before or what you did to fix it. |
|
Ah, sorry about that. The un-squashed commit history is here: https://github.com/andreer/cbor2/commits/unsquashed/ The issue I referred to was a use-after-free which was fixed in andreer@559d387 |
|
Thanks. I'll give this a new review today (Sunday). |
agronholm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find any problems. Looks good! Thanks.
|
Thank you, and happy new year! |
|
Hi, this PR was linked to the CVE-2025-68131 but I think that this is incorrect, could you please confirm if instead the correct fixing commit is this one f1d701cd2c411ee40bb1fe383afe7f365f35abf0? Thanks |
Indeed. I don't know why this PR was linked to that CVE, or how to control what PR is linked if at all. |
|
I think that it takes data from the references inside the github advisory, just created a PR to adjust it. |
Changes
Add readahead buffer to C decoder to improve performance by avoiding many small reads.
I've not added test or updated docs yet, will do later if this makes sense.
Checklist
If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):
tests/) which would fail without your patchdocs/), in case of behavior changes or newfeatures
docs/versionhistory.rst).If this is a trivial change, like a typo fix or a code reformatting, then you can ignore
these instructions.
Updating the changelog
If there are no entries after the last release, use
**UNRELEASED**as the version.If, say, your patch fixes issue #123, the entry should look like this:
If there's no issue linked, just link to your pull request instead by updating the
changelog after you've created the PR.