summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/serialization/cborlargedatavalidation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/serialization/cborlargedatavalidation.cpp')
-rw-r--r--tests/auto/corelib/serialization/cborlargedatavalidation.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/auto/corelib/serialization/cborlargedatavalidation.cpp b/tests/auto/corelib/serialization/cborlargedatavalidation.cpp
index 64191db1ef..c5cf1dc04e 100644
--- a/tests/auto/corelib/serialization/cborlargedatavalidation.cpp
+++ b/tests/auto/corelib/serialization/cborlargedatavalidation.cpp
@@ -87,25 +87,28 @@ void addValidationLargeData(qsizetype minInvalid, qsizetype maxInvalid)
toolong[0] = sizeof(v) > 4 ? 0x5b : 0x5a;
qToBigEndian(v, toolong + 1);
+ bool overflows = v > std::numeric_limits<qsizetype>::max() - 1 - qsizetype(sizeof(v));
+ CborError err = overflows ? CborErrorDataTooLarge : CborErrorUnexpectedEOF;
+
QTest::addRow("bytearray-too-big-for-qbytearray-%llx", v)
- << QByteArray(toolong, sizeof(toolong)) << 0 << CborErrorUnexpectedEOF;
+ << QByteArray(toolong, sizeof(toolong)) << 0 << err;
QTest::addRow("bytearray-chunked-too-big-for-qbytearray-%llx", v)
<< ('\x5f' + QByteArray(toolong, sizeof(toolong)) + '\xff')
- << 0 << CborErrorUnexpectedEOF;
+ << 0 << err;
QTest::addRow("bytearray-2chunked-too-big-for-qbytearray-%llx", v)
<< ("\x5f\x40" + QByteArray(toolong, sizeof(toolong)) + '\xff')
- << 0 << CborErrorUnexpectedEOF;
+ << 0 << err;
toolong[0] |= 0x20;
// QCborStreamReader::readString copies to a QByteArray first
QTest::addRow("string-too-big-for-qbytearray-%llx", v)
- << QByteArray(toolong, sizeof(toolong)) << 0 << CborErrorUnexpectedEOF;
+ << QByteArray(toolong, sizeof(toolong)) << 0 << err;
QTest::addRow("string-chunked-too-big-for-qbytearray-%llx", v)
<< ('\x7f' + QByteArray(toolong, sizeof(toolong)) + '\xff')
- << 0 << CborErrorUnexpectedEOF;
+ << 0 << err;
QTest::addRow("string-2chunked-too-big-for-qbytearray-%llx", v)
<< ("\x7f\x60" + QByteArray(toolong, sizeof(toolong)) + '\xff')
- << 0 << CborErrorUnexpectedEOF;
+ << 0 << err;
}
}