From d71bf6428ab71b1041c5c23973e13c92117ad122 Mon Sep 17 00:00:00 2001 From: VulpesThesis Date: Fri, 28 Aug 2026 11:11:57 +0100 Subject: [PATCH] Skip 4-byte Magic on corrupted message If we start scanning for DLT\x01 in the beginning of the corrupted message and the message magic isnt corrupted, we will be returning the same message, thus breaking the dlt read. --- dlt/dlt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dlt/dlt.py b/dlt/dlt.py index 67cd27b..4652d94 100644 --- a/dlt/dlt.py +++ b/dlt/dlt.py @@ -658,7 +658,11 @@ def _find_next_header(self): :rtype: int """ with open(self.filename, "rb") as fobj: - last_position = self.file_position # pylint: disable=access-member-before-definition + # Skip past the 4-byte DLT\x01 magic of the known-bad message. + # Starting at file_position would find its own magic at offset 0, + # causing the caller to treat it as unrecoverable and break. + # This only happens if the magic isn't also corrupted. + last_position = self.file_position + 4 # pylint: disable=access-member-before-definition fobj.seek(last_position) buf = fobj.read(1024) while buf: