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

Back to archive index
MinGW Notification List mingw****@lists*****
Wed Nov 13 08:38:20 JST 2019


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



  Open Date: 2019-10-19 17:38
Last Update: 2019-11-12 23:38

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:
2019-11-12 23:38 Updated by: keith

Comment:

I've updated my original patch, to implement the stratagem I outlined earlier.
With this applied, and also with the following addition to my original test
case:

 1.  --- a/tc39687.cc        2019-11-12 23:06:48.688108980 +0000
 2.  +++ b/tc39687.cc        2019-11-11 22:55:10.816277321 +0000
 3.  @@ -19,12 +19,14 @@
 4.     { std::cerr << "Verified input length: " << len << "; "
 5.         << std::strerror(errno) << '\n';
 6.     }
 7.   }
 8.    
 9.   int main()
10.  -{ const char *lang = std::getenv("LC_CTYPE");
11.  +{
12.  +  std::setlocale(LC_ALL, "" );
13.  +  const char *lang = std::getenv("LC_CTYPE");
14.     std::setlocale(LC_CTYPE, (lang == nullptr) ? "" : lang );
15.     std::cout << "Locale: " << std::setlocale(LC_CTYPE, NULL) << '\n';
16.     const wchar_t* wstr = L"A wstring-\u00df\u6c34\U0001d10b"; // or L"A wstring-ß水𝄋"
17.     print_wide(wstr);
18.   }

With these changes, I can successfully run the test case on my Win7 VM, where I
now see:

$ LC_CTYPE="English_United Kingdom.65001" /e/tc39687.exe
Locale: English_United Kingdom.1252
Multibyte string: A wstring-ÃYæ°´ð?"<
Length, including '\0': 20

Note that the output of the converted string data is garbled, (because the
console is actually incapable of rendering UTF-8 encoded data), but the length
determination is now correct.

I propose incorporating this modification into mingwrt-5.3.



---------------------------------------------------------------------
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