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 struct.pack('0p', bytes) by vstinner · Pull Request #157071 · python/cpython Conversation
|
|
In Python 3.14 and older, On Python 3.15 and newer, struct.pack() uses Well, it's better to avoid a buffer overflow anyway :-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ah, I forgot to mention that the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Oh, I forgot that Python 3.13 and 3.14 uses the old internal |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-157129 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-157130 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-157131 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
gh-156939: Fix struct.pack('0p', bytes) (GH-157071) If the Pascal string is empty (size=0), do not write the size prefix. Previously, a NUL byte was written outsize the buffer (buffer overflow). In practice, the write remains into allocated memory and is silently ignored: no memory is corrupted. (cherry picked from commit 23525c9) Co-authored-by: Victor Stinner <[email protected]>
gh-156939: Fix struct.pack('0p', bytes) (GH-157071) If the Pascal string is empty (size=0), do not write the size prefix. Previously, a NUL byte was written outsize the buffer (buffer overflow). In practice, the write remains into allocated memory and is silently ignored: no memory is corrupted. (cherry picked from commit 23525c9) Co-authored-by: Victor Stinner <[email protected]>
There was an error while loading. Please reload this page.
|
On Python 3.14 and older, if the import struct size = 512 res = struct.pack(f'{size}s0p', b'x' * size, b'ignored') print(len(res)) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
If the Pascal string is empty (size=0), do not write the size prefix. Previously, a NUL byte was written outsize the buffer (buffer overflow). In practice, the write remains into allocated memory and is silently ignored: no memory is corrupted.
If the Pascal string is empty (size=0), do not write the size prefix. Previously, a NUL byte was written outsize the buffer (buffer overflow). In practice, the write remains into allocated memory and is silently ignored: no memory is corrupted. (cherry picked from commit 23525c9) Co-authored-by: Victor Stinner <[email protected]>
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.