File: CVE-2025-5455.diff

package info (click to toggle)
qtbase-opensource-src 5.15.15%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 350,700 kB
  • sloc: cpp: 2,089,913; ansic: 336,851; xml: 115,491; python: 9,447; java: 7,499; asm: 4,023; perl: 2,047; sh: 2,037; yacc: 1,687; lex: 1,333; javascript: 878; makefile: 273; objc: 70
file content (30 lines) | stat: -rw-r--r-- 1,332 bytes parent folder | download | duplicates (3)
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
Description: qDecodeDataUrl(): fix precondition violation in call to QByteArrayView::at()
 It is a precondition violation to call QByteArrayView::at() with
 size() as argument. The code used that, though, as an implicit
 end-of-string check, assuming == ' ' and == '=' would both fail for
 null bytes. Besides, QByteArrays (but most certainly QByteArrayViews)
 need not be null-terminated, so this could read even past size().
 .
 To fix, use higher-level API (startsWith()), consuming parsed tokens
 along the way.
Origin: upstream, https://download.qt.io/official_releases/qt/5.15/CVE-2025-5455-qtbase-5.15.patch
Last-Update: 2025-06-29

--- a/src/corelib/io/qdataurl.cpp
+++ b/src/corelib/io/qdataurl.cpp
@@ -76,10 +76,11 @@ Q_CORE_EXPORT bool qDecodeDataUrl(const
         }
 
         if (data.toLower().startsWith("charset")) {
-            int i = 7;      // strlen("charset")
-            while (data.at(i) == ' ')
-                ++i;
-            if (data.at(i) == '=')
+            int prefixSize = 7; // strlen("charset")
+            QLatin1String copy(data.constData() + prefixSize, data.size() - prefixSize);
+            while (copy.startsWith(QLatin1String(" ")))
+                copy = copy.mid(1);
+            if (copy.startsWith(QLatin1String("=")))
                 data.prepend("text/plain;");
         }