From f9c273457d6c507013bd22169aad08445839bf4e Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 19 Jul 2021 19:39:17 +0100 Subject: Handle exceptions from hash providers in password_hash. --- src/modules/m_password_hash.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_password_hash.cpp b/src/modules/m_password_hash.cpp index 86611d908..322923959 100644 --- a/src/modules/m_password_hash.cpp +++ b/src/modules/m_password_hash.cpp @@ -71,9 +71,17 @@ class CommandMkpasswd : public Command return CMD_FAILURE; } - std::string hexsum = hp->Generate(parameters[1]); - user->WriteNotice(parameters[0] + " hashed password for " + parameters[1] + " is " + hexsum); - return CMD_SUCCESS; + try + { + std::string hexsum = hp->Generate(parameters[1]); + user->WriteNotice(parameters[0] + " hashed password for " + parameters[1] + " is " + hexsum); + return CMD_SUCCESS; + } + catch (const ModuleException& error) + { + user->WriteNotice("*** " + name + ": " + error.GetReason()); + return CMD_FAILURE; + } } }; -- cgit v1.3.1-10-gc9f91