From 288aa195c01bfb0d2317f8afcf89ce4ed771e5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 2 Oct 2021 12:23:12 +0200 Subject: [PATCH] Added propper error checking --- src/map/IMG/imgdata.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/map/IMG/imgdata.cpp b/src/map/IMG/imgdata.cpp index 0a1d8f10..2b27db30 100644 --- a/src/map/IMG/imgdata.cpp +++ b/src/map/IMG/imgdata.cpp @@ -44,10 +44,10 @@ bool IMGData::readSubFileBlocks(QFile &file, quint64 offset, SubFile *subFile) bool IMGData::readIMGHeader(QFile &file) { char signature[7], identifier[7]; - file.read((char*)&_key, 1) && file.seek(0x10) + if (!(file.read((char*)&_key, 1) && file.seek(0x10) && read(file, signature, sizeof(signature)) && file.seek(0x41) - && read(file, identifier, sizeof(identifier)); - if (memcmp(signature, "DSKIMG", sizeof(signature)) + && read(file, identifier, sizeof(identifier))) + || memcmp(signature, "DSKIMG", sizeof(signature)) || memcmp(identifier, "GARMIN", sizeof(identifier))) { _errorString = "Not a Garmin IMG file"; return false;