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-101703: use `PyOS_snprintf` instead of `sprintf` by sobolevn · Pull Request #101729 · python/cpython Conversation
|
|
Ok, the first part with constant sized elements is done. Now, more complex ones. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks like we have |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Almost done! There are a couple left, but I don't quite understand the code and I will highly appreciate help / advice on these cases:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🤖 New build scheduled with the buildbot fleet by @sobolevn for commit 9bc0864 🤖 If you want to schedule another build, you need to add the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🤖 New build scheduled with the buildbot fleet by @sobolevn for commit c7dd348 🤖 If you want to schedule another build, you need to add the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Yhg1s @gvanrossum it is ready to be reviewed :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I've made the requested changes, thanks for the suggestions 👍 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Yhg1s can you please review again? :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🤖 New build scheduled with the buildbot fleet by @sobolevn for commit 8a95f08 🤖 If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I've merged it with the latest Does anyone want to take a look once again, please? 😉 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
snprintf instead of sprintfPyOS_snprintf instead of sprintf
|
🤖 New build scheduled with the buildbot fleet by @sobolevn for commit 3e8e61f 🤖 If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🤖 New build scheduled with the buildbot fleet by @sobolevn for commit d82e315 🤖 If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
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.
This now has merge conflicts
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
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.
sprintf is indeed insecure generally: https://rules.sonarsource.com/c/RSPEC-6069 But, for our cases - I was not able to find a single insecure place, so I don't mark this PR as :security:
In the past, I saw people introducing bugs and security vulnerabilities by attempting to make linters happy about getting rid of "dangerous functions".
Python provides advances functions to format strings in a safe way: PyBytes_FromFormat() and PyUnicode_FromFormat(). Moreover, there is also _PyBytesWriter and _PyUnicodeWriter internal API which can be used to "create" a new string in a safe way (without having to handle memory directly).
If a string is longer than expected, PyOS_snprintf() truncates the string, but your change ignores PyOS_snprintf() result and so the string is ignored silently. I am not convinced that these changes are worth it:
For example, the PR changes FindAddress() to use PyOS_snprintf(), but it keeps alloca() which is IMO way more problematic. Using PyBytes_FromFormat() would be safer here: the function takes care of memory management and allocates memory on the heap, there is no risk of stack overflow.
If you want me to review this PR, I would prefer smaller PRs with a more precise scope and goal.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The worst example that I recall:
Commit message of the fix: Well, at that time, PHP had no automated test suite, and running tests showed the regression. But well, it's surprising how using "safer" function can introduce a major security vulnerability. The bug allowed to bypass any kind of login page (implemented with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I wanted to close this PR anyway, I think that we should do it on a per-usage approach. Easier to review, easier to merge. |
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.