Skip to content
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

Unify/simplify the MultiByteToWideChar() code and add wrappers for open()/stat() #1907

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

bit2shift
Copy link

@bit2shift bit2shift commented May 21, 2019

This is the patch I mentioned on #1066 (comment).
Patches 2 subtle buffer overruns in:

// cchWideChar is the size, in characters, of the buffer indicated by lpWideCharStr.
// It was erroneously being passed twice that origina value, the corresponding number of bytes.
MultiByteToWideChar(CP_UTF8, 0, fname, -1, wfname, sz);
                                                   ^^
MultiByteToWideChar(CP_UTF8, 0, mode, -1, wmode, sz);
                                                 ^^

by way of unifying duplicate code into a separate function: utf8_to_utf16().
Also added a corresponding wrapper for open() -> _wopen().

Pending: dealing with the unsolved problem with modules located in Unicode paths.
Edit: dealt with.

@coveralls
Copy link

coveralls commented May 21, 2019

Coverage Status

Coverage decreased (-0.02%) to 85.047% when pulling 13df637 on bit2shift:windows-unicode into ad9fc9f on stedolan:master.

@bit2shift
Copy link
Author

Noteworthy: I switched from alloca() to jv_mem_calloc() since UNC paths have no length restriction.
Besides, alloca()'d memory in utf8_to_utf16() wouldn't be accessible to parent functions.

bit2shift added 2 commits May 22, 2019 02:35
Add its prototype to util.h to make it available to other TUs
@bit2shift bit2shift changed the title Unify/simplify the MultiByteToWideChar() code and add an open() wrapper Unify/simplify the MultiByteToWideChar() code and add wrappers for open()/stat() May 22, 2019
@jqlang jqlang locked and limited conversation to collaborators May 23, 2019
@itchyny itchyny added the bug label Jun 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants