qt5base-lts/tests/auto/corelib
Jüri Valdmann 8e47474baf QJsonDocument: Avoid overflow of string lengths
The added test case contains the binary JSON equivalent of

    ["ž"]

with the modification that the string's length has been set to INT_MAX. In
Value::usedStorage this length is used through the pointer d like so

    s = sizeof(int) + sizeof(ushort) * qFromLittleEndian(*(int *)d);

Because 2 * INT_MAX is UINT_MAX-1, the expression as a whole evaluates to 2,
which is considered a valid storage size. However, when converting this binary
JSON into ordinary JSON we will attempt to construct a QString of length
INT_MAX.

Fixed by using String::isValid instead of Value::usedStorage. This method
already takes care to avoid the overflow problem. Additionally, I've tried in
this patch to clarify the behavior of Value::isValid a bit by writing it in a
style that is hopefully more amenable to structural induction.

Finally, the test case added in my previous patch had the wrong file extension
and is renamed in this one.

Task-number: QTBUG-61969
Change-Id: I45d891f2467a71d8d105822ef7eb1a73c3efa67a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-05-14 10:52:47 +00:00
..
animation qtbase: cleanup BLACKLIST files 2018-02-13 15:20:33 +00:00
codecs Replace Q_DECL_OVERRIDE with override where possible 2017-09-19 11:53:42 +00:00
global Fix thread_local test 2018-02-23 13:23:01 +00:00
io tst_qresourceengine: Fix test for configurations with builtin_testdata 2018-05-07 07:59:37 +00:00
itemmodels QItemSelectionModel: More fixes for is(Column/Row)Selected 2018-04-30 19:01:14 +00:00
kernel tst_QEventLoop: Remove unconditional qWait() 2018-04-10 08:32:21 +00:00
mimetypes QMimeDatabase: fix assert when fetching data for invalid mimetype 2018-04-06 07:19:01 +00:00
plugin tst_QLibrary: Ensure installation order of testdata libs 2018-03-02 07:20:04 +00:00
serialization QJsonDocument: Avoid overflow of string lengths 2018-05-14 10:52:47 +00:00
statemachine tst_QStateMachine: Don't use unconditional waits 2018-04-04 07:07:40 +00:00
thread Atomics: remove requirement for alignment equality with plain types 2018-04-24 17:36:42 +00:00
tools Tests: Fix clang warnings about unused variables and captures 2018-05-02 09:36:00 +00:00
corelib.pro Create corelib/serialization and move existing file formats into it 2018-01-26 20:59:50 +00:00