summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/cqm_dsk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/formats/cqm_dsk.cpp')
-rw-r--r--src/lib/formats/cqm_dsk.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/formats/cqm_dsk.cpp b/src/lib/formats/cqm_dsk.cpp
index 47fa0fddfbe..850d223da7a 100644
--- a/src/lib/formats/cqm_dsk.cpp
+++ b/src/lib/formats/cqm_dsk.cpp
@@ -258,8 +258,9 @@ const char *cqm_format::extensions() const noexcept
int cqm_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) const
{
uint8_t h[3];
- size_t actual;
- io.read_at(0, h, 3, actual);
+ auto const [err, actual] = read_at(io, 0, h, 3);
+ if (err || (3 != actual))
+ return 0;
if (h[0] == 'C' && h[1] == 'Q' && h[2] == 0x14)
return FIFID_SIGN;
@@ -269,11 +270,10 @@ int cqm_format::identify(util::random_read &io, uint32_t form_factor, const std:
bool cqm_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image &image) const
{
- size_t actual;
const int max_size = 4*1024*1024; // 4MB ought to be large enough for any floppy
std::vector<uint8_t> imagebuf(max_size);
uint8_t header[CQM_HEADER_SIZE];
- io.read_at(0, header, CQM_HEADER_SIZE, actual);
+ read_at(io, 0, header, CQM_HEADER_SIZE); // FIXME: check for errors and premature EOF
int sector_size = get_u16le(&header[0x03]);
int sector_per_track = get_u16le(&header[0x10]);
@@ -317,8 +317,9 @@ bool cqm_format::load(util::random_read &io, uint32_t form_factor, const std::ve
uint64_t cqm_size;
if (io.length(cqm_size))
return false;
- std::vector<uint8_t> cqmbuf(cqm_size);
- io.read_at(0, &cqmbuf[0], cqm_size, actual);
+ auto const [err, cqmbuf, actual] = read_at(io, 0, cqm_size);
+ if (err || (actual != cqm_size))
+ return false;
// decode the RLE data
for (int s = 0, pos = CQM_HEADER_SIZE + comment_size; pos < cqm_size; )