File: upstream_cve-2025-5455_fix_data_assertion_error.diff

package info (click to toggle)
qt6-base 6.8.2%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 297,960 kB
  • sloc: cpp: 1,896,460; ansic: 374,195; xml: 142,138; python: 20,680; java: 8,229; asm: 4,009; javascript: 2,290; sh: 1,690; perl: 1,028; makefile: 130
file content (28 lines) | stat: -rw-r--r-- 1,349 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
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/6.8/CVE-2025-5455-qtbase-6.8.patch
Last-Update: 2025-06-29

--- a/src/corelib/io/qdataurl.cpp
+++ b/src/corelib/io/qdataurl.cpp
@@ -47,10 +47,10 @@ Q_CORE_EXPORT bool qDecodeDataUrl(const QUrl &uri, QString &mimeType, QByteArray
         QLatin1StringView textPlain;
         constexpr auto charset = "charset"_L1;
         if (QLatin1StringView{data}.startsWith(charset, Qt::CaseInsensitive)) {
-            qsizetype i = charset.size();
-            while (data.at(i) == ' ')
-                ++i;
-            if (data.at(i) == '=')
+            QByteArrayView copy = data.sliced(charset.size());
+            while (copy.startsWith(' '))
+                copy.slice(1);
+            if (copy.startsWith('='))
                 textPlain = "text/plain;"_L1;
         }