Skip to content

Commit

Permalink
[qtcontacts-sqlite] Check QContactExtendedDetail data type before des…
Browse files Browse the repository at this point in the history
…erialization. Fixes JB#51806

Only deserialize the QContactExtendedDetail::data() value if it is a
QByteArray.
  • Loading branch information
blammit committed Oct 29, 2020
1 parent 9267656 commit 4298f38
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/engine/contactreader.cpp
Expand Up @@ -627,14 +627,23 @@ static void setValues(QContactExtendedDetail *detail, QSqlQuery *query, const in
{
setValue(detail, QContactExtendedDetail::FieldName, query->value(offset + 0));

QByteArray bytes = query->value(offset + 1).toByteArray();
QBuffer buffer(&bytes);
buffer.open(QIODevice::ReadOnly);
QDataStream in(&buffer);
in.setVersion(QDataStream::Qt_5_6);
QVariant deserialized;
in >> deserialized;
setValue(detail, QContactExtendedDetail::FieldData, deserialized);
QVariant rawValue = query->value(offset + 1);
if (rawValue.type() == QVariant::Type(QMetaType::QByteArray)) {
QByteArray bytes = rawValue.toByteArray();
QBuffer buffer(&bytes);
buffer.open(QIODevice::ReadOnly);
QDataStream in(&buffer);
in.setVersion(QDataStream::Qt_5_6);
QVariant deserialized;
in >> deserialized;

if (deserialized.isValid()) {
setValue(detail, QContactExtendedDetail::FieldData, deserialized);
return;
}
}

setValue(detail, QContactExtendedDetail::FieldData, rawValue);
}

static QMap<QString, int> contextTypes()
Expand Down

0 comments on commit 4298f38

Please sign in to comment.