From: ShadowFlare Date: Sun, 26 Jul 2009 22:41:43 +0000 (-0600) Subject: Fixed crashing in SFileListFiles when encountering an invalid block table index. X-Git-Url: https://sfsrealm.hopto.org/projects/?a=commitdiff_plain;h=7a5243c768cd08bfc2f901e03c3a9ed1b1f95e39;p=SFmpqapi.git Fixed crashing in SFileListFiles when encountering an invalid block table index. --- diff --git a/SFmpqapi.cpp b/SFmpqapi.cpp index a42fa43..55f9fb8 100644 --- a/SFmpqapi.cpp +++ b/SFmpqapi.cpp @@ -1520,7 +1520,7 @@ BOOL SFMPQAPI WINAPI SFileListFiles(MPQHANDLE hMPQ, LPCSTR lpFileLists, FILELIST for (i=0;iMpqHeader.dwHashTableSize;i++) { lpListBuffer[i].dwFileExists = 0; lpListBuffer[i].szFileName[0] = 0; - if ((mpqOpenArc->lpHashTable[i].dwBlockTableIndex&0xFFFFFFFE)!=0xFFFFFFFE) { + if ((mpqOpenArc->lpHashTable[i].dwBlockTableIndex&0xFFFFFFFE)!=0xFFFFFFFE && mpqOpenArc->lpHashTable[i].dwBlockTableIndex < mpqOpenArc->MpqHeader.dwBlockTableSize) { lpListBuffer[i].lcLocale = mpqOpenArc->lpHashTable[i].lcLocale; DWORD dwBlockIndex = mpqOpenArc->lpHashTable[i].dwBlockTableIndex; lpListBuffer[i].dwCompressedSize = mpqOpenArc->lpBlockTable[dwBlockIndex].dwCompressedSize; @@ -1684,7 +1684,7 @@ BOOL SFMPQAPI WINAPI SFileListFiles(MPQHANDLE hMPQ, LPCSTR lpFileLists, FILELIST for (i=0;iMpqHeader.dwHashTableSize;i++) { lpListBuffer[i].dwFileExists = 0; lpListBuffer[i].szFileName[0] = 0; - if ((mpqOpenArc->lpHashTable[i].dwBlockTableIndex&0xFFFFFFFE)!=0xFFFFFFFE) { + if ((mpqOpenArc->lpHashTable[i].dwBlockTableIndex&0xFFFFFFFE)!=0xFFFFFFFE && mpqOpenArc->lpHashTable[i].dwBlockTableIndex < mpqOpenArc->MpqHeader.dwBlockTableSize) { lpListBuffer[i].lcLocale = mpqOpenArc->lpHashTable[i].lcLocale; DWORD dwBlockIndex = mpqOpenArc->lpHashTable[i].dwBlockTableIndex; lpListBuffer[i].dwCompressedSize = mpqOpenArc->lpBlockTable[dwBlockIndex].dwCompressedSize;