summaryrefslogtreecommitdiffstats
path: root/wsd/FileServer.cpp
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-03-09 09:05:30 +0100
committerAndras Timar <andras.timar@collabora.com>2020-03-09 09:46:33 +0100
commita7d3efdd4ea921430442ae427fb4c25a2d9afcc8 (patch)
tree1fe70e6ff1cb0323d9df5e6190156a0fc7fccd43 /wsd/FileServer.cpp
parentRemove unused filterHandleRequest unit test hook. (diff)
downloadonline-a7d3efdd4ea921430442ae427fb4c25a2d9afcc8.tar.gz
online-a7d3efdd4ea921430442ae427fb4c25a2d9afcc8.zip
Introduce StringVector::equals()
Allows comparing tokens with C strings without a heap allocation. Do the same when comparing two tokens from two different StringVectors. And use it at all places where operator ==() has an argument, which is a StringVector::operator []() result. Change-Id: Id36eff96767ab99b235ecbd12fb14446a3efa869 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90201 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'wsd/FileServer.cpp')
-rw-r--r--wsd/FileServer.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index d7db1e80cd..ce9e127560 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -147,8 +147,8 @@ bool isConfigAuthOk(const std::string& userProvidedUsr, const std::string& userP
std::vector<unsigned char> saltData;
StringVector tokens = LOOLProtocol::tokenize(securePass, '.');
if (tokens.size() != 5 ||
- tokens[0] != "pbkdf2" ||
- tokens[1] != "sha512" ||
+ !tokens.equals(0, "pbkdf2") ||
+ !tokens.equals(1, "sha512") ||
!Util::dataFromHexString(tokens[3], saltData))
{
LOG_ERR("Incorrect format detected for secure_password in config file." << useLoolconfig);
@@ -167,7 +167,8 @@ bool isConfigAuthOk(const std::string& userProvidedUsr, const std::string& userP
stream << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(userProvidedPwdHash[j]);
// now compare the hashed user-provided pwd against the stored hash
- return stream.str() == tokens[4];
+ std::string string = stream.str();
+ return tokens.equals(4, string.c_str());
#else
const std::string pass = config.getString("admin_console.password", "");
LOG_ERR("The config file has admin_console.secure_password setting, "