QmlDebug/QmlProfiler: Fix integer range checks

The packet protocol should check if the number of bytes to be read is
positive.

The check in QmlTypedEvent is supposed to happen before we cast the
number to the more restrictive type. Furthermore, if subtype doesn't
fit the range constraint, we don't have to do anything at all as the
default rangeType is already set before.

Change-Id: I45006f8dd752787d59960948b222148d78509aba
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Ulf Hermann
2018-06-06 14:50:55 +02:00
parent 909f30f006
commit 36d5d3acc1
2 changed files with 5 additions and 10 deletions

View File

@@ -42,9 +42,8 @@ QDataStream &operator>>(QDataStream &stream, QmlTypedEvent &event)
RangeType rangeType = MaximumRangeType;
if (!stream.atEnd()) {
stream >> subtype;
rangeType = static_cast<RangeType>(subtype);
if (rangeType < 0 || rangeType > MaximumRangeType)
rangeType = MaximumRangeType;
if (subtype >= 0 && subtype < MaximumRangeType)
rangeType = static_cast<RangeType>(subtype);
} else {
subtype = -1;
}