Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-764

IconvLCPTranscoder::transcode() is wrong at wcstombs() usage.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 2.1.0
    • 2.2.0
    • Miscellaneous
    • None
    • Operating System: Other
      Platform: Other
    • 15608

    Description

      File: xerces-c-src2_1_0/src/xercesc/util/Transcoders/Iconv/IconvTransService.cpp
      Function:
      bool IconvLCPTranscoder::transcode( const XMLCh* const toTranscode
      , char* const toFill
      , const unsigned int maxBytes)

      The following logic is wrong, because wLent is the number of wide characters.
      unsigned int wLent = getWideCharLength(toTranscode);
      ::wcstombs(toFill, wideCharBuf, maxBytes);
      // Cap it off just in case
      toFill[wLent] = 0;

      It should be as follows (error handling is omitted),
      size_t mblen;
      mblen = ::wcstombs(toFill, wideCharBuf, maxBytes);
      toFill[mblen] = 0;

      Attachments

        Activity

          People

            Unassigned Unassigned
            inoue@ariel-networks.com inoue
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: