1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

Added propper error checking

This commit is contained in:
Martin Tůma 2021-10-02 12:23:12 +02:00
parent 8d92cf6d86
commit 288aa195c0

View File

@ -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;