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

Commit 0518f8cb authored by Daniel Rosenberg's avatar Daniel Rosenberg
Browse files

snapuserd: Fix PrepareReadAhead

When checking the instead of current, and when checking the position, we could underflow,
which would get caught by UBSAN

Bug: 177104308
Test: Map cow file with xor op or copy op at position 0
Change-Id: I4fba1982419e08b58759ec893e238175d245dbfc
parent bb0a7642
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ void ReadAheadThread::PrepareReadAhead(uint64_t* source_offset, int* pending_ops
            if (op->type == kCowCopyOp) {
                next_offset *= BLOCK_SZ;
            }
            if (next_offset != (*source_offset - nr_consecutive * BLOCK_SZ)) {
            if (next_offset + nr_consecutive * BLOCK_SZ != *source_offset) {
                break;
            }
            nr_consecutive += 1;