aboutsummaryrefslogtreecommitdiff
path: root/src/SFileOpenArchive.cpp
diff options
context:
space:
mode:
authorLadislav Zezula <zezula@volny.cz>2024-04-21 22:35:07 +0200
committerGitHub <noreply@github.com>2024-04-21 22:35:07 +0200
commit3b65b373bc822a0ee0410edb80fa4ecfc0b454da (patch)
tree6d46b40a782aa282e60b3e9583d5a9120287c3b3 /src/SFileOpenArchive.cpp
parent605222393594f5885b877bfc0086dae756674965 (diff)
parent7250eca739f060dd6984b9ea74a9fbb8b0a7c353 (diff)
Merge pull request #346 from ladislav-zezula/LZ_GabeShermanFoundBugs
Fixed bugs found by Gabe Sherman
Diffstat (limited to 'src/SFileOpenArchive.cpp')
-rw-r--r--src/SFileOpenArchive.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/SFileOpenArchive.cpp b/src/SFileOpenArchive.cpp
index a97ecea..587aa96 100644
--- a/src/SFileOpenArchive.cpp
+++ b/src/SFileOpenArchive.cpp
@@ -501,10 +501,14 @@ bool WINAPI SFileOpenArchive(
break;
}
- // Set the size of file sector
- ha->dwSectorSize = (0x200 << ha->pHeader->wSectorSize);
+ // Set the size of file sector. Be sure to check for integer overflow
+ if((ha->dwSectorSize = (0x200 << ha->pHeader->wSectorSize)) == 0)
+ dwErrCode = ERROR_FILE_CORRUPT;
+ }
- // Verify if any of the tables doesn't start beyond the end of the file
+ // Verify if any of the tables doesn't start beyond the end of the file
+ if(dwErrCode == ERROR_SUCCESS)
+ {
dwErrCode = VerifyMpqTablePositions(ha, FileSize);
}