Re: svn commit: r1482282 - svn_nls_init on Windows
From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Tue, 14 May 2013 17:05:00 +0100 (BST)
Bert Huijben wrote:
Hi Bert. While you're here, I see two more problems with this piece of code, just by inspection. (I haven't tested this.)
(1) Inserting a UCS-2 string into a UTF-8 error message will surely fail in one way or another.
(2) Just below this error handling, the code to write the null terminator is bogus.
outbytes = outlength = 3 * (inwords + 1);
outbytes = WideCharToMultiByte(CP_UTF8, 0, ucs2_path, inwords,
if (outbytes == 0)
The existing code puts the null terminator in the wrong place. This will truncate any path that is longer than PATH_MAX/2, and will fail to terminate any path shorter than PATH_MAX/2. WideCharToMultiByte() explicitly does not promise to write a null terminator. This code will work despite this bug iff:
* path length < MAX_PATH/2
and either of:
* WideCharToMultiByte() adds a null terminator
Otherwise, it will produce the wrong result.
This is an archived mail posted to the Subversion Dev mailing list.