summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-03-20 17:55:31 -0300
committerThiago Macieira <thiago.macieira@intel.com>2020-03-27 16:45:59 -0300
commitbff56f953adc8ce743aa774d6ad09725d8b9bc45 (patch)
tree1ecb9a27c9361e9cf73a7a57c29b51795bf6bafe /tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
parent783d574b932288b61f915b28d5b7b9c5a979f58e (diff)
tst_QCborValue: Prepare for 64-bit QVectors in Qt 6
Change-Id: Ief61acdfbe4d4b5ba1f0fffd15fe1e921aab0a72 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp')
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
index 488771d059..6d8161c1f9 100644
--- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
+++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
@@ -1709,13 +1709,21 @@ void tst_QCborValue::validation_data()
// They are meant to ensure we don't pre-allocate a lot of memory
// unnecessarily and possibly crash the application. The actual number of
// elements in the stream is only 2, so we should get an unexpected EOF
- // error. QCborValue internally uses 16 bytes per element, so we get to
- // 2 GB at 2^27 elements.
- QTest::addRow("very-large-array-no-overflow") << raw("\x9a\x07\xff\xff\xff" "\0\0") << 0 << CborErrorUnexpectedEOF;
- QTest::addRow("very-large-array-overflow1") << raw("\x9a\x40\0\0\0" "\0\0") << 0 << CborErrorUnexpectedEOF;
-
- // this makes sure we don't accidentally clip to 32-bit: sending 2^32+2 elements
- QTest::addRow("very-large-array-overflow2") << raw("\x9b\0\0\0\1""\0\0\0\2" "\0\0") << 0 << CborErrorDataTooLarge;
+ // error. QCborValue internally uses 16 bytes per element, so we get to 2
+ // GB at 2^27 elements (32-bit) or, theoretically, 2^63 bytes at 2^59
+ // elements (64-bit).
+ if (sizeof(QVector<int>::size_type) == sizeof(int)) {
+ // 32-bit sizes (Qt 5 and 32-bit platforms)
+ QTest::addRow("very-large-array-no-overflow") << raw("\x9a\x07\xff\xff\xff" "\0\0") << 0 << CborErrorUnexpectedEOF;
+ QTest::addRow("very-large-array-overflow1") << raw("\x9a\x40\0\0\0" "\0\0") << 0 << CborErrorUnexpectedEOF;
+
+ // this makes sure we don't accidentally clip to 32-bit: sending 2^32+2 elements
+ QTest::addRow("very-large-array-overflow2") << raw("\x9b\0\0\0\1""\0\0\0\2" "\0\0") << 0 << CborErrorDataTooLarge;
+ } else {
+ // 64-bit Qt 6
+ QTest::addRow("very-large-array-no-overflow") << raw("\x9b\x07\xff\xff\xff" "\xff\xff\xff\xff" "\0\0");
+ QTest::addRow("very-large-array-overflow") << raw("\x9b\x40\0\0\0" "\0\0\0\0" "\0\0");
+ }
}
void tst_QCborValue::validation()