Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-162

Problem printing string with embedded NULL character

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.10.0
    • None
    • None
    • log4cxx-svn-427970
      linux / gcc

    Description

      It's exactly the problem described in:
      http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg01650.html

      ---- COPY OF MESSAGE ----

      Problem printing string with embedded NULL character

      Venkatraju
      Sat, 29 Jul 2006 19:30:11 -0700

      Hi,

      Printing a string with embedded NULL character causes
      MbstowcsCharsetDecoder::decode to go into an infinite loop trying to
      consume that character.

      Test case below:
      ------
      #include <iostream>
      #include <log4cxx/basicconfigurator.h>

      using namespace log4cxx;

      int main()

      { BasicConfigurator::configure(); std::string badStr; badStr.append("hello"); badStr.append(1, '\0'); badStr.append("world"); LOG4CXX_ERROR(Logger::getRootLogger(), badStr); return 0; } --------- Fixed with this patch: --- Index: src/charsetdecoder.cpp =================================================================== --- src/charsetdecoder.cpp (revision 390980) +++ src/charsetdecoder.cpp (working copy) @@ -178,6 +178,12 @@ stat = append(out, buf); in.position(in.position() + converted); }

      +
      + if (in.remaining() > 0 && (src == 0))

      { + // Found embedded NULL in string + stat = APR_BADARG; + break; + }

      }
      return stat;
      }


      Can someone merge this into the log4cxx trunk? Please let me know if I
      need to provide more info.

      Thanks,
      Venkat

      Attachments

        Activity

          People

            carnold@apache.org Curt Arnold
            hunger hunger
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: