Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-106844: Fix null-bytes handling inLCMapStringEx in_winapi#106857
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Modules/_winapi.c Outdated
| _winapi.LCMapStringEx | ||
| locale:LPCWSTR | ||
| locale:unicode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why change it forlocale?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I just backported the solution from927b5af#diff-42415407f8d0ef2d42e29d13d979f633e3543770e62c3871e1101ad532d336a8R1518
So, 3.11 and 3.12 would match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The code would be simpler if keep the LPCWSTR converter here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I agree. We don't need to treat this argument any differently - it's only thesrc argument that requires special handling.
Modules/_winapi.c Outdated
| srcLen= (int)srcLenAsSsize; | ||
| if (srcLen!=srcLenAsSsize) { | ||
| srcLen=-1; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
How would it work for large (more than2**32 characters) string containing NUL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It doesn't, but that's the caller's responsibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LCMapStringEx() will simply return the result for the truncated input. It is bad. How is the caller expected to detect this problem if it only occurs in special circumferences?
What doesLCMapStringEx() return for large input not containing NUL? Most likely it fails. We should either emulate this response (raise an OSError with the same Windows error code) or simply raise an OverflowError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Please address my comments. If the code in 3.11 has the same flaws, it should be fixed too.
Modules/_winapi.c Outdated
| _winapi.LCMapStringEx | ||
| locale:LPCWSTR | ||
| locale:unicode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The code would be simpler if keep the LPCWSTR converter here.
bedevere-bot commentedJul 19, 2023
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 |
I don't think the fix is as simple as bringing forward this fix - the underlying code should be identical in current versions, it was just earlier versions that needed a different fix because of existing bugs in the Unicode converters. I'll take a fresh look and see what ought to happen here. Chances are, updating the |
Looks like the changes to make argument clinic support Leaving the |
Opened#107832 for my propositions. |
#107832 fixed also other issues. |
Uh oh!
There was an error while loading.Please reload this page.
I've changed the clinic definition + backported changes made by@zooba in927b5af#diff-42415407f8d0ef2d42e29d13d979f633e3543770e62c3871e1101ad532d336a8