From d05afb3ca376d0683409c992e4a1cf5a665517dc Mon Sep 17 00:00:00 2001 From: Naram Qashat Date: Sun, 8 Aug 2010 22:30:00 -0400 Subject: [PATCH] Fix an error in db-upgrade on sha256 encrypted passwords. --- src/tools/db-upgrade.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tools/db-upgrade.cpp b/src/tools/db-upgrade.cpp index fe9480803..eb7a1a978 100644 --- a/src/tools/db-upgrade.cpp +++ b/src/tools/db-upgrade.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #ifndef _WIN32 static const std::string C_LBLUE = "\033[1;34m"; @@ -193,9 +194,9 @@ int main(int argc, char *argv[]) size_t colon = password.find(':'); if (colon != std::string::npos && password.substr(0, colon) != "plain") { - std::string hash = password.substr(colon + 1), iv; + std::string hash = password.substr(colon + 1), iv, hashm = password.substr(0, colon); unsigned len; - if (password.substr(0, colon) == "sha256") + if (hashm == "sha256") { colon = hash.find(':'); iv = hash.substr(colon + 1); @@ -218,7 +219,7 @@ int main(int argc, char *argv[]) else hash.clear(); delete [] hash_decoded; - password = password.substr(0, colon + 1); + password = hashm + ":"; if (!hash.empty()) password += hash; if (!iv.empty()) @@ -236,6 +237,8 @@ int main(int argc, char *argv[]) out << line << std::endl; } + std::cout << "Upgrade complete!" << std::endl; + in.close(); out.close();