mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Added propper error checking
This commit is contained in:
parent
8d92cf6d86
commit
288aa195c0
@ -44,10 +44,10 @@ bool IMGData::readSubFileBlocks(QFile &file, quint64 offset, SubFile *subFile)
|
|||||||
bool IMGData::readIMGHeader(QFile &file)
|
bool IMGData::readIMGHeader(QFile &file)
|
||||||
{
|
{
|
||||||
char signature[7], identifier[7];
|
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, signature, sizeof(signature)) && file.seek(0x41)
|
||||||
&& read(file, identifier, sizeof(identifier));
|
&& read(file, identifier, sizeof(identifier)))
|
||||||
if (memcmp(signature, "DSKIMG", sizeof(signature))
|
|| memcmp(signature, "DSKIMG", sizeof(signature))
|
||||||
|| memcmp(identifier, "GARMIN", sizeof(identifier))) {
|
|| memcmp(identifier, "GARMIN", sizeof(identifier))) {
|
||||||
_errorString = "Not a Garmin IMG file";
|
_errorString = "Not a Garmin IMG file";
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user