From 33bdae86c2345db9514addbf9d5a698eada56fb2 Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Mon, 17 May 2021 12:57:54 +0200 Subject: Added alignment-aware block encryption/decryption --- src/SFileListFile.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/SFileListFile.cpp') 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); -- cgit v1.2.3