wok-next view truecrypt/stuff/patches/fix-invalid-characters.patch @ rev 20036

Fix truecrypt. Although cryptography is not easy. Use it at your own risk.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sun Oct 22 19:31:48 2017 +0300 (2017-10-22)
parents
children
line source
1 From 646679da4d79bf7f8af22c44c7ae8498086a88a6 Mon Sep 17 00:00:00 2001
2 From: Mounir IDRASSI <mounir.idrassi@idrix.fr>
3 Date: Fri, 18 Mar 2016 16:25:48 +0100
4 Subject: [PATCH] Linux: Completely fix gcc-5 "Invalid characters encountered"
5 issue on mount. It was caused by an issue of gcc-5 STL implementation that is
6 causing char* pointers retrieved from std::string using c_str method to
7 become invalid in the child of a child process (after two fork calls). The
8 workaround is to first copy the std:string values in the child before calling
9 the second fork.
11 ---
12 src/Platform/Unix/Process.cpp | 24 ++++++++++++++++++++++--
13 1 file changed, 22 insertions(+), 2 deletions(-)
15 diff --git a/src/Platform/Unix/Process.cpp b/src/Platform/Unix/Process.cpp
16 index 388bda6..0770364 100644
17 --- a/src/Platform/Unix/Process.cpp
18 +++ b/src/Platform/Unix/Process.cpp
19 @@ -53,13 +53,33 @@ namespace VeraCrypt
20 try
21 {
22 int argIndex = 0;
23 + /* Workaround for gcc 5.X issue related to the use of STL (string and list) with muliple fork calls.
24 + *
25 + * The char* pointers retrieved from the elements of parameter "arguments" are no longer valid after
26 + * a second fork is called. "arguments" was created in the parent of the current child process.
27 + *
28 + * The only solution is to copy the elements of "arguments" parameter in a local string array on this
29 + * child process and then use char* pointers retrieved from this local copies before calling fork.
30 + *
31 + * gcc 4.x doesn't suffer from this issue.
32 + *
33 + */
34 + string argsCopy[array_capacity (args)];
35 if (!execFunctor)
36 - args[argIndex++] = const_cast <char*> (processName.c_str());
37 + {
38 + argsCopy[argIndex++] = processName;
39 + }
41 foreach (const string &arg, arguments)
42 {
43 - args[argIndex++] = const_cast <char*> (arg.c_str());
44 + argsCopy[argIndex++] = arg;
45 }
46 +
47 + for (int i = 0; i < argIndex; i++)
48 + {
49 + args[i] = const_cast <char*> (argsCopy[i].c_str());
50 + }
51 +
52 args[argIndex] = nullptr;
54 if (inputData)