From 3c7e775a9a4af177cd999066ec3656387d337d6a Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Tue, 8 Jun 2021 15:19:09 +0200 Subject: [PATCH] AK: Utf8CodePointIterator: Don't output full string to debug output When a code point is invalid, the full string was outputted to the debug output. For large strings, this can make the system quite slow. Furthermore, one of the cases incorrectly assumed the data to be null terminated. This patch modifies the debug statements not to print the full string. This fixes oss-fuzz issue 35050. --- AK/Utf8View.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AK/Utf8View.cpp b/AK/Utf8View.cpp index f967781644..9023cc50da 100644 --- a/AK/Utf8View.cpp +++ b/AK/Utf8View.cpp @@ -246,13 +246,13 @@ u32 Utf8CodePointIterator::operator*() const if (!first_byte_makes_sense) { // The first byte of the code point doesn't make sense: output a replacement character - dbgln("First byte doesn't make sense, bytes: {}", StringView { (const char*)m_ptr, m_length }); + dbgln("First byte doesn't make sense: {:#02x}.", m_ptr[0]); return 0xFFFD; } if (code_point_length_in_bytes > m_length) { // There is not enough data left for the full code point: output a replacement character - dbgln("Not enough bytes (need {}, have {}), first byte is: {:#02x}, '{}'", code_point_length_in_bytes, m_length, m_ptr[0], (const char*)m_ptr); + dbgln("Not enough bytes (need {}, have {}), first byte is: {:#02x}.", code_point_length_in_bytes, m_length, m_ptr[0]); return 0xFFFD; }