aboutsummaryrefslogtreecommitdiff
path: root/src/SFileAttributes.cpp
diff options
context:
space:
mode:
authorLadislav Zezula <zezula@volny.cz>2023-08-04 11:19:49 +0200
committerLadislav Zezula <zezula@volny.cz>2023-08-04 11:19:49 +0200
commit8debce7eab1cfb7a145d592d757b75e7cac83610 (patch)
tree928021fc7f634eaf5a8686feb1e85d745523c918 /src/SFileAttributes.cpp
parent31dd4a36fc6b49330915886f56ac9a42d3e3150c (diff)
Fixed heap overflow in handling of file patch
Diffstat (limited to 'src/SFileAttributes.cpp')
-rw-r--r--src/SFileAttributes.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/SFileAttributes.cpp b/src/SFileAttributes.cpp
index e22a09f..dbcc456 100644
--- a/src/SFileAttributes.cpp
+++ b/src/SFileAttributes.cpp
@@ -391,7 +391,10 @@ DWORD SAttrLoadAttributes(TMPQArchive * ha)
pbAttrFile[cbAttrFile] = 0;
// Load the entire file to memory
- SFileReadFile(hFile, pbAttrFile, cbAttrFile, &dwBytesRead, NULL);
+ if(!SFileReadFile(hFile, pbAttrFile, cbAttrFile, &dwBytesRead, NULL))
+ ha->dwFlags |= (GetLastError() == ERROR_FILE_CORRUPT) ? MPQ_FLAG_MALFORMED : 0;
+
+ // Parse the (attributes)
if(dwBytesRead == cbAttrFile)
dwErrCode = LoadAttributesFile(ha, pbAttrFile, cbAttrFile);