Commit b8c6262d authored by David Faure's avatar David Faure
Browse files

Serializer: fix endianness on magic; rewind before load.

* QDataStream swaps bytes on little-endian machines so
reinterpret_cast onto a quint32 just can't work.

* Create another QDataStream so that KCalCore can start with
deserializing the header. If we just pass along "input",
it is positioned after the header -- and can't go much further
anyway, it points to a buffer only as big as the header (!)
parent 6cf0d1f7
Pipeline #42262 passed with stage
in 7 minutes and 7 seconds
......@@ -34,8 +34,11 @@ namespace {
bool isSerializedBinary(QIODevice &data)
quint32 magic = 0;
data.peek(reinterpret_cast<char *>(&magic), sizeof(magic));
const QByteArray buffer = data.peek(4);
// Use QDataStream because of endianness
quint32 magic;
QDataStream input(buffer);
input >> magic;
return magic == IncidenceBase::magicSerializationIdentifier();
......@@ -83,7 +86,8 @@ bool SerializerPluginKCalCore::deserialize(Item &item, const QByteArray &label,
case KCalendarCore::Incidence::TypeUnknown:
return false;
input >> base;
QDataStream stream(&data);
stream >> base;
incidence = base.staticCast<KCalendarCore::Incidence>();
} else {
// Use the old format
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment