Am 2017-05-18 um 14:35 schrieb Piotr Caban:
Could you please check if there really is such a length limit in wchar version of the function?
I'm working on it. What is the deal with wchar_t vs WCHAR in the implementation vs the tests?
Also I am not sure the existing test establishes the -3 for the A version. I'll extend it if my reading is right.
WideCharToMultiByte(CP_ACP, 0, target_w, -1, target, wcslen(target_w) + 1, NULL, NULL);
You can use MAX_PATH here instead of wcslen(target_w)+1.
I guess the app is required to pass a pointer to a string that's at least MAX_PATH in size because there is no way to communicate the length. Given that constraint it should be safe to convert MAX_PATH chars.
However, with the actual implementation an app could get away with a shorter array if the actual path is shorter I think, and the app may be able to know the length in advance. So blindly converting MAX_PATH characters could cause a problem.