Return early from QTimeZone constructor if alleged IANA ID is invalid
If the ID isn't even valid, don't waste cycles trying to make sense of it as identifying a time-zone. Add test of an invalid ID that provoked an integer overflow on trying to parse it as a POSIX zone specification. Fixes: QTBUG-92842 Change-Id: Ib80bbb88c11c0484ce0358acabbdc25c5bd8e0b3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
e41dbfd3a4
commit
ec8808c302
@ -334,6 +334,9 @@ QTimeZone::QTimeZone() noexcept
|
||||
|
||||
QTimeZone::QTimeZone(const QByteArray &ianaId)
|
||||
{
|
||||
// If invalid (other than empty), reject immediately:
|
||||
if (!ianaId.isEmpty() && !QTimeZonePrivate::isValidId(ianaId))
|
||||
return;
|
||||
// Try and see if it's a CLDR UTC offset ID - just as quick by creating as
|
||||
// by looking up.
|
||||
d = new QUtcTimeZonePrivate(ianaId);
|
||||
|
@ -1000,6 +1000,9 @@ void tst_QTimeZone::malformed()
|
||||
barf = QTimeZone("QtC+09,,MA");
|
||||
if (barf.isValid())
|
||||
QCOMPARE(barf.offsetFromUtc(now), 0);
|
||||
barf = QTimeZone("UTCC+14:00,-,");
|
||||
if (barf.isValid())
|
||||
QCOMPARE(barf.daylightTimeOffset(now), -14 * 3600);
|
||||
}
|
||||
|
||||
void tst_QTimeZone::utcTest()
|
||||
|
Loading…
x
Reference in New Issue
Block a user