Skip to content

Commit 1fecea8

Browse files
FozzTexxtschak909
authored andcommitted
Fix D64 to not read past the end of a sector on large reads.
1 parent 41b8fc2 commit 1fecea8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/meatloaf/disk/d64.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ uint16_t D64MStream::readFile(uint8_t *buf, uint16_t size)
382382

383383
if (size > 0)
384384
{
385+
// Only read up to the bytes remaining in this sector
386+
size = std::min(size, (uint16_t) (block_size - sector_offset % block_size));
387+
385388
bytesRead += readContainer(buf, size);
386389
sector_offset += bytesRead;
387390

0 commit comments

Comments
 (0)