File: upstream_c33e581b_Skip-two-bytes-on-invalid-header-signature-in-seekToNextHeaderToken-.patch

package info (click to toggle)
kf6-karchive 6.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,124 kB
  • sloc: cpp: 10,437; python: 37; sh: 14; makefile: 5
file content (32 lines) | stat: -rw-r--r-- 1,185 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
From c33e581b5ca6e049f4443074394f47ed54ba680d Mon Sep 17 00:00:00 2001
From: Azhar Momin <azhar-momin@outlook.com>
Date: Wed, 9 Apr 2025 22:08:08 +0530
Subject: [PATCH] Skip two bytes on invalid header signature in
 `seekToNextHeaderToken()`

`seekAnyHeader()` advances the stream to the start of next potential
header but may not move if the stream is already positioned at a header
candidate. When encountering a token that does not match an expected
signature (i.e, PK\x03\x04 or PK\x01\x02) in `seekToNextHeaderToken()`,
manually advance the stream by two bytes to avoid re-detecting the same
invalid token in the next iteration.
---
 src/kzip.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/kzip.cpp b/src/kzip.cpp
index 0f048410..439d0bdf 100644
--- a/src/kzip.cpp
+++ b/src/kzip.cpp
@@ -387,6 +387,8 @@ static bool seekToNextHeaderToken(QIODevice *dev)
         // PK12 for the central header in case there is no data descriptor
         if (header.startsWith("PK\x03\x04") || header.startsWith("PK\x01\x02")) {
             return true;
+        } else {
+            dev->seek(dev->pos() + 2); // Skip found 'PK'
         }
     }
     return false;
-- 
GitLab