Skip to content

Commit

Permalink
Linux: fix linker type confusion that was causing crash.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
idrassi committed Jul 13, 2024
1 parent bb67a22 commit 1ee93df
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
54 changes: 27 additions & 27 deletions src/Main/GraphicUserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,32 @@

namespace VeraCrypt
{
class AdminPasswordGUIRequestHandler : public GetStringFunctor
{
public:
virtual void operator() (string &passwordStr)
{

wxString sValue;
if (Gui->GetWaitDialog())
{
Gui->GetWaitDialog()->RequestAdminPassword(sValue);
if (sValue.IsEmpty())
throw UserAbort (SRC_POS);
}
else
{
wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]);
if (dialog.ShowModal() != wxID_OK)
throw UserAbort (SRC_POS);
sValue = dialog.GetValue();
}
wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased
finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); });

StringConverter::ToSingle (wPassword, passwordStr);
}
};
#ifdef TC_MACOSX
int GraphicUserInterface::g_customIdCmdV = 0;
int GraphicUserInterface::g_customIdCmdA = 0;
Expand Down Expand Up @@ -452,33 +478,7 @@ namespace VeraCrypt

shared_ptr <GetStringFunctor> GraphicUserInterface::GetAdminPasswordRequestHandler ()
{
class AdminPasswordRequestHandler : public GetStringFunctor
{
public:
virtual void operator() (string &passwordStr)
{

wxString sValue;
if (Gui->GetWaitDialog())
{
Gui->GetWaitDialog()->RequestAdminPassword(sValue);
if (sValue.IsEmpty())
throw UserAbort (SRC_POS);
}
else
{
wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]);
if (dialog.ShowModal() != wxID_OK)
throw UserAbort (SRC_POS);
sValue = dialog.GetValue();
}
wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased
finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); });

StringConverter::ToSingle (wPassword, passwordStr);
}
};
return shared_ptr <GetStringFunctor> (new AdminPasswordRequestHandler);
return shared_ptr <GetStringFunctor> (new AdminPasswordGUIRequestHandler);
}

int GraphicUserInterface::GetCharHeight (wxWindow *window) const
Expand Down
6 changes: 3 additions & 3 deletions src/Main/TextUserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

namespace VeraCrypt
{
class AdminPasswordRequestHandler : public GetStringFunctor
class AdminPasswordTextRequestHandler : public GetStringFunctor
{
public:
AdminPasswordRequestHandler (TextUserInterface *userInterface) : UI (userInterface) { }
AdminPasswordTextRequestHandler (TextUserInterface *userInterface) : UI (userInterface) { }
virtual void operator() (string &passwordStr)
{
UI->ShowString (_("Enter your user password or administrator password: "));
Expand Down Expand Up @@ -1116,7 +1116,7 @@ namespace VeraCrypt

shared_ptr <GetStringFunctor> TextUserInterface::GetAdminPasswordRequestHandler ()
{
return shared_ptr <GetStringFunctor> (new AdminPasswordRequestHandler (this));
return shared_ptr <GetStringFunctor> (new AdminPasswordTextRequestHandler (this));
}

void TextUserInterface::ImportTokenKeyfiles () const
Expand Down
4 changes: 2 additions & 2 deletions src/Main/TextUserInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

namespace VeraCrypt
{
class AdminPasswordRequestHandler;
class AdminPasswordTextRequestHandler;
class TextUserInterface : public UserInterface
{
public:
friend class AdminPasswordRequestHandler;
friend class AdminPasswordTextRequestHandler;
TextUserInterface ();
virtual ~TextUserInterface ();

Expand Down

0 comments on commit 1ee93df

Please sign in to comment.