Add readahead buffer to C decoder#268
Conversation
|
I think a changelog entry should be added for this. |
agronholm
left a comment
There was a problem hiding this comment.
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.
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. |
Backport the patch[1] which fixes this vulnerability as mentioned in the comment[2]. Details: https://nvd.nist.gov/vuln/detail/CVE-2025-68131 [1] agronholm/cbor2@f1d701c [2] agronholm/cbor2#268 (comment) Dropped changes to the changelog from the original commit. Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com> Signed-off-by: Anuj Mittal <anuj.mittal@oss.qualcomm.com>
Source: meta-openembedded MR: 307157, 302820 Type: Security Fix Disposition: Merged from meta-openembedded ChangeID: daacf50 Description: Backport the patch[1] which fixes this vulnerability as mentioned in the comment[2]. Details: https://nvd.nist.gov/vuln/detail/CVE-2025-68131 [1] agronholm/cbor2@f1d701c [2] agronholm/cbor2#268 (comment) Dropped changes to the changelog from the original commit. Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com> Signed-off-by: Anuj Mittal <anuj.mittal@oss.qualcomm.com> Signed-off-by: Jeremy A. Puhlman <jpuhlman@mvista.com>
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.