43 lines
1.8 KiB
Diff
43 lines
1.8 KiB
Diff
From 6a61c8544b2d9c6ba1292ab43e81c47565dde6f9 Mon Sep 17 00:00:00 2001
|
|
From: Ivan Solovev <ivan.solovev@qt.io>
|
|
Date: Tue, 11 Aug 2026 14:59:18 +0200
|
|
Subject: [PATCH] QBinaryJson::fromBinaryData(): do the comparison in size_t
|
|
|
|
In Qt 6, the QBA can actually store more than UINT_MAX bytes, so
|
|
casting to uint can truncate. Use size_t instead.
|
|
|
|
Amends the port of Qt container size_type form int to qsizetype
|
|
(Qt 6.0).
|
|
|
|
Task-number: QTBUG-149036
|
|
Pick-to: 6.8 6.5
|
|
Change-Id: Ia63cd6576233e74d9cf5e8def9d3e05065a63831
|
|
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
|
|
(cherry picked from commit 721ed576391211ca53ecdaaecf6dd41df7bc962e)
|
|
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
|
|
(cherry picked from commit 897a3421f925cb73409d3138d464b8c0ab30d15d)
|
|
---
|
|
|
|
diff --git a/src/core5/serialization/qbinaryjson.cpp b/src/core5/serialization/qbinaryjson.cpp
|
|
index 7653924..869f62f 100644
|
|
--- a/src/core5/serialization/qbinaryjson.cpp
|
|
+++ b/src/core5/serialization/qbinaryjson.cpp
|
|
@@ -153,7 +153,7 @@
|
|
*/
|
|
QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation)
|
|
{
|
|
- if (uint(data.size()) < sizeof(QBinaryJsonPrivate::Header) + sizeof(QBinaryJsonPrivate::Base))
|
|
+ if (size_t(data.size()) < sizeof(QBinaryJsonPrivate::Header) + sizeof(QBinaryJsonPrivate::Base))
|
|
return QJsonDocument();
|
|
|
|
QBinaryJsonPrivate::Header h;
|
|
@@ -166,7 +166,7 @@
|
|
if (qAddOverflow(uint{sizeof(QBinaryJsonPrivate::Header)}, uint{root.size}, &size))
|
|
return QJsonDocument(); // not representable in Private::ConstData
|
|
|
|
- if (h.tag != QJsonDocument::BinaryFormatTag || h.version != 1U || size > uint(data.size()))
|
|
+ if (h.tag != QJsonDocument::BinaryFormatTag || h.version != 1U || size > size_t(data.size()))
|
|
return QJsonDocument();
|
|
|
|
std::unique_ptr<QBinaryJsonPrivate::ConstData> d
|