QSslCertificate: Guard against accessing empty QByteArray

Fixes oss-fuzz issue 29276.

Pick-to: 5.12 5.15 6.0
Change-Id: I57b0c26e5377bd6b82d9f044ae1d1d13acec996a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Robert Loehning 2021-01-08 19:21:42 +01:00
parent d7d6f8765f
commit ce90248882

View File

@ -311,7 +311,9 @@ bool QSslCertificatePrivate::parse(const QByteArray &data)
if (elem.type() == QAsn1Element::Context0Type) {
QDataStream versionStream(elem.value());
if (!elem.read(versionStream) || elem.type() != QAsn1Element::IntegerType)
if (!elem.read(versionStream)
|| elem.type() != QAsn1Element::IntegerType
|| elem.value().isEmpty())
return false;
versionString = QByteArray::number(elem.value().at(0) + 1);