[MinGW-Notify] [mingw] #39687: wcsrtombs with NULL dest pointer doesn't ignore len parameter

Back to archive index
MinGW Notification List mingw****@lists*****
Wed Jan 22 08:14:52 JST 2020

#39687: wcsrtombs with NULL dest pointer doesn't ignore len parameter

  Open Date: 2019-10-19 17:38
Last Update: 2020-01-21 23:14

URL for this Ticket:
RSS feed for this Ticket:


Last Changes/Comment on this Ticket:
2020-01-21 23:14 Updated by: keith


Following on from this, I've reviewed the complementary mbrlen(), mbrtowc(),
and mbsrtowcs() function implementations; all exhibit potentially serious, (and
potentially more difficult to rectify), defects. In particular:

  • As with the original wcsrtombs() implementation, the output length limit
    prevents proper determination of required buffer length in mbsrtowcs(),
    when initially called with an output buffer specified as NULL.
  • The codeset conversion routine, shared by all three of these functions, is
    ill equipped to handle anything other than SBCS or DBCS inputs, in spite of
    Microsoft's eventual recognition of MBCS codesets with more than two bytes
    per code point.

I'm currently undecided as to whether or not mingwrt-5.3 should be delayed,
pending resolution of these complementary issues.

Ticket Status:

      Reporter: gallickgunner
         Owner: keith
          Type: Issues
        Status: Open [Owner assigned]
      Priority: 5 - Medium
     MileStone: (None)
     Component: WSL
      Severity: 5 - Medium
    Resolution: None

Ticket details:

I'm using MinGW-gcc-6.3.0. The wcsrtombs() function as mentioned in the docs on
cppreference should return the number of bytes that would have been written to
src. However it doesn't do so on my end. It seems the implementation doesn't
ignore the length parameter when dest is passed as NULL? A similar issue was
reported and presumably fixed for the Mingw-w64 on the sourceforge site
Currently working around by passing INT_MAX as the length parameter, so it
finishes within the limit and returns the size.

I apologize in advance if this is just an issue from my end or if any other
info is missing. First time submitting a ticket :)

Ticket information of MinGW - Minimalist GNU for Windows project
MinGW - Minimalist GNU for Windows Project is hosted on OSDN

Project URL: https://osdn.net/projects/mingw/
OSDN: https://osdn.net

URL for this Ticket:
RSS feed for this Ticket:

More information about the MinGW-Notify mailing list
Back to archive index