From 3f0dd6c3ea5508d36fb83dc54094f17e4b967db1 Mon Sep 17 00:00:00 2001 From: prozacx Date: Tue, 26 Apr 2005 16:41:21 +0000 Subject: [PATCH] Added a confirmation to --makepass git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@194 726aef4b-f618-498e-8847-2d620e286838 --- main.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 66e8bfe9..094f4619 100644 --- a/main.cpp +++ b/main.cpp @@ -127,11 +127,23 @@ int main(int argc, char** argv) { } #endif /* HAVE_LIBSSL */ if ( bMakePass ) { - char* pass = getpass( "Enter Password: " ); - int iLen = strlen(pass); - CUtils::PrintMessage("Use this in the section of your config:"); - CUtils::PrintMessage("Pass = " + string((const char*) CMD5(pass, iLen)) + " -"); - memset((char*) pass, 0, iLen); // null out our pass so it doesn't sit in memory + char* pass = CUtils::GetPass("Enter Password"); + char* pass1 = (char*) malloc(strlen(pass) +1); + strcpy(pass1, pass); // Make a copy of this since it is stored in a static buffer and will be overwritten when we fill pass2 below + memset((char*) pass, 0, strlen(pass)); // null out our pass so it doesn't sit in memory + char* pass2 = CUtils::GetPass("Confirm Password"); + int iLen = strlen(pass1); + + if (strcmp(pass1, pass2) == 0) { + CUtils::PrintMessage("Use this in the section of your config:"); + CUtils::PrintMessage("Pass = " + string((const char*) CMD5(pass1, iLen)) + " -"); + } else { + CUtils::PrintError("The supplied passwords do not match"); + } + + memset((char*) pass1, 0, iLen); // null out our pass so it doesn't sit in memory + memset((char*) pass2, 0, strlen(pass2)); // null out our pass so it doesn't sit in memory + free(pass1); return 0; }