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

Back to archive index
MinGW Notification List mingw****@lists*****
Mon Mar 16 08:00:13 JST 2020


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

  Open Date: 2019-10-19 17:38
Last Update: 2020-03-15 23:00

URL for this Ticket:
    https://osdn.net//projects/mingw/ticket/39687
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=39687

---------------------------------------------------------------------

Last Changes/Comment on this Ticket:
2020-03-15 23:00 Updated by: keith

Comment:

I've now reimplemented all of wcsrtombs(), wcrtomb(), wctob(), mbsrtowcs(),
mbrtowc(), mbrlen(), and btowc(), such that all will now attempt to delegate to
a Microsoft DLL implementation, if available, and fall back to a new libmingwex
implementation, in situations where a Microsoft implementation is unavailable,
or may be unsuitable. All are included in mingwrt-5.3.

Also included in mingwrt-5.3, is a replacement for mbsinit() ... in libmingwex
only; AFAICT, there never has been a Microsoft implementation for this, but the
original libmingwex implementation would always report initial state, which is
incorrect in cases where any of the restartable conversion functions have left
pending state from an incomplete conversion.

The libmingwex implementations of each of these functions conform, as far as is
practicable, to ISO-C99 and to POSIX.1; Microsoft's implementations are likely
nonconforming. Users wishing to always use the libmingwex implementations, (to
exploit their more reliable standards conformity), should avoid linking with
any of Microsoft's non-free runtime DLLs — i.e. link with MSVCRT.DLL only, and
do not define __MSVCRT_VERSION__ — and should define either _ISOC99_SOURCE, or
_ISOC11_SOURCE, before including any header file, in any translation unit which
calls any of the above-named functions. (These measures disable call delegation
to the Microsoft function implementations, thus ensuring that the libmingwex
implementations are used).

Of the new libmingwex implementations, mbrtowc() has proved particularly
challenging; in fact, it is not possible to implement this in a truly ISO-C99
conforming manner, while limited by Microsoft's unfortunate choice of UTF-16LE
as the underlying representation of wchar_t ... there is simply no safe way to
return a surrogate pair in a single call! Thus, the new implementation
incorporates special, non-standard handling for this abnormal case, as
described in this manpage.



---------------------------------------------------------------------
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:
    https://osdn.net/projects/mingw/ticket/39687
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=39687



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