1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2026-06-10 14:57:02 -05:00

Linux: fix CentOS 6 build with GCC 4.4

CentOS 6 builds VeraCrypt with GCC 4.4.7 and -std=c++0x. That compiler does not support range-based for loops, and its libstdc++ does not provide std::string::back() or std::string::pop_back().

Avoid those constructs in the affected Unix/Linux code paths: use VeraCrypt's existing foreach helper when iterating PKCS#11 object handles, and use indexing plus erase() when trimming trailing slashes from PATH entries.

This keeps the code valid for newer Linux toolchains while restoring compatibility with the CentOS 6 build environment.
This commit is contained in:
Mounir IDRASSI
2026-05-26 20:49:36 +09:00
parent 9b20099255
commit 4ad36447b2
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -220,7 +220,7 @@ namespace VeraCrypt
throw;
}
for(const CK_OBJECT_HANDLE & dataHandle: GetObjects(slotId, CKO_DATA))
foreach(const CK_OBJECT_HANDLE & dataHandle, GetObjects(slotId, CKO_DATA))
{
SecurityTokenKeyfile keyfile;
keyfile.Handle = dataHandle;
+4 -4
View File
@@ -1440,8 +1440,8 @@ namespace VeraCrypt
while (getline(ss, token, ':'))
{
// remove any trailing slashes from the token
while (!token.empty() && token.back() == '/')
token.pop_back();
while (!token.empty() && token[token.length() - 1] == '/')
token.erase(token.length() - 1);
if (token.empty())
continue;
@@ -1459,8 +1459,8 @@ namespace VeraCrypt
free(resolvedEntry);
// remove any trailing slashes from the token
while (!entryPath.empty() && entryPath.back() == '/')
entryPath.pop_back();
while (!entryPath.empty() && entryPath[entryPath.length() - 1] == '/')
entryPath.erase(entryPath.length() - 1);
// perform check again if the resolved path is different from the original (symlink)
if (dirPath == entryPath || dirPath.find(entryPath + "/") == 0)