From 1e77bc78e43e0ad4d23e706a503093e1b2a31c6e Mon Sep 17 00:00:00 2001 From: Nikolay Zlatev Date: Wed, 7 Jul 2021 10:37:38 +0300 Subject: [PATCH] CipherSettings: fix crash with empty RawKey Fix crash when CipherSettings::getPassword() is called with empty RawKey. Related issue #2743 --- src/CipherSettings.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CipherSettings.cpp b/src/CipherSettings.cpp index f7e32155..1a25ae12 100644 --- a/src/CipherSettings.cpp +++ b/src/CipherSettings.cpp @@ -16,7 +16,11 @@ std::string CipherSettings::getPassword() const return sqlb::escapeString(password); } else { // Remove the '0x' part at the beginning - return "\"x'" + password.substr(2) + "'\""; + if (password.length() > 2) { + return "\"x'" + password.substr(2) + "'\""; + } + + return "''"; } }