VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform
diff options
context:
space:
mode:
authorAlexander Karzhenkov <karzhenkov@mail.ru>2019-06-06 14:41:42 +0500
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2019-06-06 11:41:42 +0200
commit6f1ebacd398948712928b17c7792193c411be927 (patch)
treec2a4259d15b14d39aaeb00034da3ad201c80a605 /src/Platform
parent7c28ae7e450576abf77c504fffc46e47b297c2fd (diff)
downloadVeraCrypt-6f1ebacd398948712928b17c7792193c411be927.tar.gz
VeraCrypt-6f1ebacd398948712928b17c7792193c411be927.zip
Some cleanup related to "Invalid characters..." on mount issue. (#453)
* Revert previous commit * Fix "Invalid characters..." issue by not using "foreach" macro The "foreach" macro creates a copy of the container. This copy is destroyed immediately after the iteration is completed. C-strings pointers passed to the local array were invalidated with destroying of "std::string"s contained in the copy.
Diffstat (limited to 'src/Platform')
-rw-r--r--src/Platform/Unix/Process.cpp26
1 files changed, 3 insertions, 23 deletions
diff --git a/src/Platform/Unix/Process.cpp b/src/Platform/Unix/Process.cpp
index 4a7f9a15..ac8598f0 100644
--- a/src/Platform/Unix/Process.cpp
+++ b/src/Platform/Unix/Process.cpp
@@ -53,33 +53,13 @@ namespace VeraCrypt
try
{
int argIndex = 0;
- /* Workaround for gcc 5.X issue related to the use of STL (string and list) with muliple fork calls.
- *
- * The char* pointers retrieved from the elements of parameter "arguments" are no longer valid after
- * a second fork is called. "arguments" was created in the parent of the current child process.
- *
- * The only solution is to copy the elements of "arguments" parameter in a local string array on this
- * child process and then use char* pointers retrieved from this local copies before calling fork.
- *
- * gcc 4.x doesn't suffer from this issue.
- *
- */
- string argsCopy[array_capacity (args)];
if (!execFunctor)
- {
- argsCopy[argIndex++] = processName;
- }
-
- foreach (const string &arg, arguments)
- {
- argsCopy[argIndex++] = arg;
- }
+ args[argIndex++] = const_cast <char*> (processName.c_str());
- for (int i = 0; i < argIndex; i++)
+ for (list<string>::const_iterator it = arguments.begin(); it != arguments.end(); it++)
{
- args[i] = const_cast <char*> (argsCopy[i].c_str());
+ args[argIndex++] = const_cast <char*> (it->c_str());
}
-
args[argIndex] = nullptr;
if (inputData)