Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
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))
}
return stat;
}
Can someone merge this into the log4cxx trunk? Please let me know if I
need to provide more info.
Thanks,
Venkat