Skip to content

Commit 1ee93df

Browse files
committed
Linux: fix linker type confusion that was causing crash.
The class AdminPasswordRequestHandler was defined in several places in the same namespace and the linker was picking up one definition for constructor and the other one when calling virtual method. Now we use different named for different implementations.
1 parent bb67a22 commit 1ee93df

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

src/Main/GraphicUserInterface.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@
3737

3838
namespace VeraCrypt
3939
{
40+
class AdminPasswordGUIRequestHandler : public GetStringFunctor
41+
{
42+
public:
43+
virtual void operator() (string &passwordStr)
44+
{
45+
46+
wxString sValue;
47+
if (Gui->GetWaitDialog())
48+
{
49+
Gui->GetWaitDialog()->RequestAdminPassword(sValue);
50+
if (sValue.IsEmpty())
51+
throw UserAbort (SRC_POS);
52+
}
53+
else
54+
{
55+
wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]);
56+
if (dialog.ShowModal() != wxID_OK)
57+
throw UserAbort (SRC_POS);
58+
sValue = dialog.GetValue();
59+
}
60+
wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased
61+
finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); });
62+
63+
StringConverter::ToSingle (wPassword, passwordStr);
64+
}
65+
};
4066
#ifdef TC_MACOSX
4167
int GraphicUserInterface::g_customIdCmdV = 0;
4268
int GraphicUserInterface::g_customIdCmdA = 0;
@@ -452,33 +478,7 @@ namespace VeraCrypt
452478

453479
shared_ptr <GetStringFunctor> GraphicUserInterface::GetAdminPasswordRequestHandler ()
454480
{
455-
class AdminPasswordRequestHandler : public GetStringFunctor
456-
{
457-
public:
458-
virtual void operator() (string &passwordStr)
459-
{
460-
461-
wxString sValue;
462-
if (Gui->GetWaitDialog())
463-
{
464-
Gui->GetWaitDialog()->RequestAdminPassword(sValue);
465-
if (sValue.IsEmpty())
466-
throw UserAbort (SRC_POS);
467-
}
468-
else
469-
{
470-
wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]);
471-
if (dialog.ShowModal() != wxID_OK)
472-
throw UserAbort (SRC_POS);
473-
sValue = dialog.GetValue();
474-
}
475-
wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased
476-
finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); });
477-
478-
StringConverter::ToSingle (wPassword, passwordStr);
479-
}
480-
};
481-
return shared_ptr <GetStringFunctor> (new AdminPasswordRequestHandler);
481+
return shared_ptr <GetStringFunctor> (new AdminPasswordGUIRequestHandler);
482482
}
483483

484484
int GraphicUserInterface::GetCharHeight (wxWindow *window) const

src/Main/TextUserInterface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030

3131
namespace VeraCrypt
3232
{
33-
class AdminPasswordRequestHandler : public GetStringFunctor
33+
class AdminPasswordTextRequestHandler : public GetStringFunctor
3434
{
3535
public:
36-
AdminPasswordRequestHandler (TextUserInterface *userInterface) : UI (userInterface) { }
36+
AdminPasswordTextRequestHandler (TextUserInterface *userInterface) : UI (userInterface) { }
3737
virtual void operator() (string &passwordStr)
3838
{
3939
UI->ShowString (_("Enter your user password or administrator password: "));
@@ -1116,7 +1116,7 @@ namespace VeraCrypt
11161116

11171117
shared_ptr <GetStringFunctor> TextUserInterface::GetAdminPasswordRequestHandler ()
11181118
{
1119-
return shared_ptr <GetStringFunctor> (new AdminPasswordRequestHandler (this));
1119+
return shared_ptr <GetStringFunctor> (new AdminPasswordTextRequestHandler (this));
11201120
}
11211121

11221122
void TextUserInterface::ImportTokenKeyfiles () const

src/Main/TextUserInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
namespace VeraCrypt
2121
{
22-
class AdminPasswordRequestHandler;
22+
class AdminPasswordTextRequestHandler;
2323
class TextUserInterface : public UserInterface
2424
{
2525
public:
26-
friend class AdminPasswordRequestHandler;
26+
friend class AdminPasswordTextRequestHandler;
2727
TextUserInterface ();
2828
virtual ~TextUserInterface ();
2929

0 commit comments

Comments
 (0)