Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04ca59d6 authored by Daniel Zheng's avatar Daniel Zheng
Browse files

libsnapshot: add compatibility check

Ensure that cow was written by v3 writer for the data_length check to
work. All ops written by v2 writer should go through the decompressor
path if a compressor was used.

Test: cow_api_test
Change-Id: I053d6fdaf29ef7001e68f43b45d5a3ff1a36b1c3
parent ec63f6f1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -685,7 +685,8 @@ ssize_t CowReader::ReadData(const CowOperation* op, void* buffer, size_t buffer_
    } else {
        offset = GetCowOpSourceInfoData(*op);
    }
    if (!decompressor || op->data_length == header_.block_size) {
    if (!decompressor ||
        ((op->data_length == header_.block_size) && (header_.prefix.major_version == 3))) {
        CowDataStream stream(this, offset + ignore_bytes, op->data_length - ignore_bytes);
        return stream.ReadFully(buffer, buffer_size);
    }