gh-106844: Fix null-bytes handling in LCMapStringEx in _winapi#106857
gh-106844: Fix null-bytes handling in LCMapStringEx in _winapi#106857sobolevn wants to merge 6 commits intopython:mainfrom
LCMapStringEx in _winapi#106857Conversation
Modules/_winapi.c
Outdated
| _winapi.LCMapStringEx | ||
|
|
||
| locale: LPCWSTR | ||
| locale: unicode |
There was a problem hiding this comment.
Why change it for locale?
There was a problem hiding this comment.
I just backported the solution from 927b5af#diff-42415407f8d0ef2d42e29d13d979f633e3543770e62c3871e1101ad532d336a8R1518
So, 3.11 and 3.12 would match.
There was a problem hiding this comment.
The code would be simpler if keep the LPCWSTR converter here.
There was a problem hiding this comment.
I agree. We don't need to treat this argument any differently - it's only the src argument that requires special handling.
Modules/_winapi.c
Outdated
| srcLen = (int)srcLenAsSsize; | ||
| if (srcLen != srcLenAsSsize) { | ||
| srcLen = -1; | ||
| } |
There was a problem hiding this comment.
How would it work for large (more than 2**32 characters) string containing NUL?
There was a problem hiding this comment.
It doesn't, but that's the caller's responsibility.
There was a problem hiding this comment.
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 does LCMapStringEx() 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.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
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.
The code would be simpler if keep the LPCWSTR converter here.
|
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. |
I've changed the clinic definition + backported changes made by @zooba in 927b5af#diff-42415407f8d0ef2d42e29d13d979f633e3543770e62c3871e1101ad532d336a8