-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Remove "w" format of PyParse_ParseTuple() #53096
Comments
"w" format is dangerous because it doesn't give the size of the buffer: the caller may write outside the buffer (buffer overflow). "w*" and "w#" formats are fine. It looks like "w" format is not used in trunk nor py3k (only w# and w*). |
Attached patch removes "w" format, cleanups the code for "w*" and "w#" formats, and update the documentation. |
I'd point out that "w#" is mostly useless too. It's supposed to return a read-write buffer, but as the doc says it also doesn't support "mutable objects", since it isn't able to properly lock/pin the buffer; therefore it probably doesn't support anything useful. |
See also bpo-8592: 'y' does not check for embedded NUL bytes. |
"w#" is not only useless but also not used in py3k source code. "w" is also not used. Only "w*" is used by fnctl and socket modules. The problem with w# is that the caller cannot "release" the buffer and so we cannot lock the buffer. I don't know exactly what happens if you get a pointer to a bytearray, release the GIL and then use it, whereas another thread modifies and/or destroys the bytearray object. (I suppose that something bad will happen, like a segfault) |
New (improved) version of the patch:
|
See also bpo-8926. |
Commited to 3.2 (r82208), blocked in 3.1 (r82209). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: