This is an archive of the discontinued LLVM Phabricator instance.

Win32 support: wcsnrtombs and mbsnrtowcs don't handle null output buffers correctly.
ClosedPublic

Authored by andrew.j.c.parker on Jul 20 2015, 2:11 AM.

Details

Summary

According to the linux man pages:

http://man7.org/linux/man-pages/man3/wcsnrtombs.3.html
http://man7.org/linux/man-pages/man3/mbsnrtowcs.3.html

"If dest is NULL, len is ignored, and the conversion proceeds as above..."

The current code still uses len when the output buffer is NULL, i.e. the len *isn't* ignored.

The fix simply forces len to be the maz val for size_t when the output buffer is NULL.

Diff Detail

Event Timeline

andrew.j.c.parker retitled this revision from to Win32 support: wcsnrtombs and mbsnrtowcs don't handle null output buffers correctly..
andrew.j.c.parker updated this object.
andrew.j.c.parker set the repository for this revision to rL LLVM.
mclow.lists accepted this revision.Jul 21 2015, 7:59 AM
mclow.lists edited edge metadata.

I believe that this accomplishes what Andrew is trying to do.
With the changes that I noted, this LGTM.

src/support/win32/support.cpp
79

You write (size_t)-1; here, but below in this same routine is the code:

return static_cast<size_t>(-1);

Please use one or the other.

This revision is now accepted and ready to land.Jul 21 2015, 7:59 AM
andrew.j.c.parker edited edge metadata.
andrew.j.c.parker removed rL LLVM as the repository for this revision.

Updated patch based on comment about casting.

andrew.j.c.parker set the repository for this revision to rL LLVM.Jul 21 2015, 6:29 PM

Looks like patch was not committed.

andrew.j.c.parker marked an inline comment as done.Dec 4 2016, 12:17 AM

Looks like patch was not committed.

Sorry, my eyes aren't really on this project at the moment so haven't been keeping up.

Anything I can do to help? Do I need to do anything extra?

If you don't have commit privs; I will commit it for you. (but it will be Thursday when I do so)

mclow.lists closed this revision.Jan 23 2019, 10:28 AM

(Finally) committed as revision 351971