From 5f4d7f89db1ab95bdb000689a756068e918cb5b5 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sat, 10 Aug 2024 01:35:52 -0700 Subject: [PATCH] core/log: fix log corruption with messages at 29 second deltas 29, or 0x1d is used as a marker to mean the log level and time delta cannot fit in a single byte, and the time delta will be a varint following the current byte. Prior to this commit, 29 second deltas would be written as 0x1d instead of 0x1d1d, which the parser interpreted as a hint to read the next byte, causing the parser to become offset by one byte and all following logs to be potentially corrupt. --- src/core/logging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/logging.cpp b/src/core/logging.cpp index 649eb947..01f9a90b 100644 --- a/src/core/logging.cpp +++ b/src/core/logging.cpp @@ -469,7 +469,7 @@ bool EncodedLogWriter::write(const LogMessage& message) { quint8 field = compressedTypeOf(message.type); auto secondDelta = this->lastMessageTime.secsTo(message.time); - if (secondDelta > 29) { + if (secondDelta >= 29) { // 0x1d = followed by delta int // 0x1e = followed by epoch delta int field |= (secondDelta < 0xffff ? 0x1d : 0x1e) << 3;