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

Commit e1132a9c authored by David Anderson's avatar David Anderson
Browse files

snapuserd: Fix ubsan when reading a single aligned sector.

When a read request is for a single sector, and the sector is
block-aligned, it falls into the ReadAlignedSector path, which assumes
block-sized reads. Fix this by clamping the expected size.

Bug: 291862304
Test: manual test of ReadWorker::ReadAlignedSector
      full OTA
Change-Id: I00e460c333e8a9a4dc2433443e3633f3d794da1d
parent 4a33c22c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ bool ReadWorker::ReadAlignedSector(sector_t sector, size_t sz) {
                    return false;
                }

                ret = BLOCK_SZ;
                ret = std::min(BLOCK_SZ, read_size);
            }

            read_size -= ret;