GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||
GeezerVison is showing github.com — gh-156939: Fix memory corruption check in fcntl by vstinner · Pull Request #157103 · python/cpython Conversation
|
|
Python 3.13 and 3.14 are not affected. They fail with an error if the buffer size is larger than 1024 bytes. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
With this change, I'm not sure that it's still needed to have a "fast path" (is it really faster?) for buffer smaller than or equal to 1024 bytes (the code path which doesn't use PyBytesWriter).
// Truncate the trailing guard bytes return PyBytesWriter_FinishWithSize(writer, len);
The updated code now allocates extra 8 bytes and then resize the bytes object to truncate the last 8 bytes. It's less efficient than the previous code which relies on the fact that bytes objects always end with a trailing NUL byte. IMO it's better to have better check for memory overflow, than paying attention of the performance of such short operation.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
On a CI building Python in release mode, test_ioctl does crash :-( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Ah, I just found and fixed a typo. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Currently, the code is correct. It relies on the fact that bytes objects always end with a NUL byte. This change is mostly needed if we decide to implement the check to detect buffer overflow in PyBytesWriter: PR gh-156943. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I included this change in PR gh-156943, so I close this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.