sahvx655-wq opened a new pull request, #711: URL: https://github.com/apache/logging-log4cxx/pull/711
This PR fixes an issue in several Transcoder conversion functions that could enter an infinite loop when processing malformed character sequences, such as unpaired UTF-16 surrogate values or invalid UTF-8 byte sequences. When malformed input is encountered, the decoder returns the error sentinel 0xFFFF. In certain transcoding paths, the iterator was not advanced after such a decode failure. As a result, the same invalid input could be processed repeatedly, causing the calling thread to loop indefinitely. Updated the relevant Transcoder::decode and Transcoder::encode implementations for: std::wstring std::basic_string<UniChar> CFStringRef Track the iterator position before each decode operation. If decoding returns 0xFFFF and the iterator has not advanced, manually advance the iterator to guarantee forward progress. Substitute malformed input with the replacement character (LOSSCHAR) instead of repeatedly processing the same invalid sequence Tests Added regression tests to verify malformed input is handled safely and does not result in hangs: testDecodeUniChar_Malformed_DoesNotHang testEncodeUniChar_Malformed_DoesNotHang -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
