VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform/Unix/Process.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Platform/Unix/Process.cpp')
-rw-r--r--src/Platform/Unix/Process.cpp33
1 files changed, 6 insertions, 27 deletions
diff --git a/src/Platform/Unix/Process.cpp b/src/Platform/Unix/Process.cpp
index 4a7f9a15..46b14a1e 100644
--- a/src/Platform/Unix/Process.cpp
+++ b/src/Platform/Unix/Process.cpp
@@ -30,7 +30,7 @@ namespace VeraCrypt
string Process::Execute (const string &processName, const list <string> &arguments, int timeOut, ProcessExecFunctor *execFunctor, const Buffer *inputData)
{
char *args[32];
- if (array_capacity (args) <= arguments.size())
+ if (array_capacity (args) <= (arguments.size() + 1))
throw ParameterTooLarge (SRC_POS);
#if 0
@@ -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)
@@ -139,7 +119,6 @@ namespace VeraCrypt
throw_sys_if (fcntl (exceptionPipe.GetReadFD(), F_SETFL, O_NONBLOCK) == -1);
vector <char> buffer (4096), stdOutput (4096), errOutput (4096), exOutput (4096);
- buffer.clear ();
stdOutput.clear ();
errOutput.clear ();
exOutput.clear ();
@@ -190,12 +169,12 @@ namespace VeraCrypt
if (!exOutput.empty())
{
- auto_ptr <Serializable> deserializedObject;
+ unique_ptr <Serializable> deserializedObject;
Exception *deserializedException = nullptr;
try
{
- shared_ptr <Stream> stream (new MemoryStream (ConstBufferPtr ((byte *) &exOutput[0], exOutput.size())));
+ shared_ptr <Stream> stream (new MemoryStream (ConstBufferPtr ((uint8 *) &exOutput[0], exOutput.size())));
deserializedObject.reset (Serializable::DeserializeNew (stream));
deserializedException = dynamic_cast <Exception*> (deserializedObject.get());
}