aboutsummaryrefslogtreecommitdiff
path: root/src/SFileListFile.cpp
diff options
context:
space:
mode:
authorLadislav Zezula <ladislav.zezula@avast.com>2021-05-17 12:57:54 +0200
committerLadislav Zezula <ladislav.zezula@avast.com>2021-05-17 12:57:54 +0200
commit33bdae86c2345db9514addbf9d5a698eada56fb2 (patch)
treeff40d644d75b5976b051bf6534e459805e9d184c /src/SFileListFile.cpp
parenta3332c7c9bc36f13aace6543ebc719f833882dfc (diff)
Added alignment-aware block encryption/decryption
Diffstat (limited to 'src/SFileListFile.cpp')
-rw-r--r--src/SFileListFile.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/SFileListFile.cpp b/src/SFileListFile.cpp
index e2b8166..a1e16b0 100644
--- a/src/SFileListFile.cpp
+++ b/src/SFileListFile.cpp
@@ -90,6 +90,7 @@ static TListFileCache * CreateListFileCache(
DWORD dwFlags)
{
TListFileCache * pCache = NULL;
+ size_t cchWildCardAligned = 0;
size_t cchWildCard = 0;
DWORD dwBytesRead = 0;
@@ -99,10 +100,13 @@ static TListFileCache * CreateListFileCache(
// Append buffer for name mask, if any
if(szWildCard != NULL)
+ {
cchWildCard = strlen(szWildCard) + 1;
+ cchWildCardAligned = (cchWildCard + 3) & 0xFFFFFFFC;
+ }
// Allocate cache for one file block
- pCache = (TListFileCache *)STORM_ALLOC(BYTE, sizeof(TListFileCache) + cchWildCard + dwFileSize + 1);
+ pCache = (TListFileCache *)STORM_ALLOC(BYTE, sizeof(TListFileCache) + cchWildCardAligned + dwFileSize + 1);
if(pCache != NULL)
{
// Clear the entire structure
@@ -117,7 +121,7 @@ static TListFileCache * CreateListFileCache(
}
// Fill-in the rest of the cache pointers
- pCache->pBegin = (LPBYTE)(pCache + 1) + cchWildCard;
+ pCache->pBegin = (LPBYTE)(pCache + 1) + cchWildCardAligned;
// Load the entire listfile to the cache
PfnLoadFile(pHandle, pCache->pBegin, dwFileSize, &dwBytesRead);