diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2019-12-16 09:00:08 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2019-12-16 09:04:36 +0000 |
commit | 93cc18b0f6fa5fa8144079a4f51904d8b3087e94 (patch) | |
tree | c8a75cca8c08c8a21df4c7d8267c20c33a84a518 /src/util | |
parent | ccc53e43c5464058171d6291da861a88184b230e (diff) |
util: Don't allow DecodeBase64(...) of strings with embedded NUL characters
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/strencodings.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp index 8f2d05f03b..dfd8961cb7 100644 --- a/src/util/strencodings.cpp +++ b/src/util/strencodings.cpp @@ -191,6 +191,12 @@ std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid) std::string DecodeBase64(const std::string& str, bool* pf_invalid) { + if (!ValidAsCString(str)) { + if (pf_invalid) { + *pf_invalid = true; + } + return {}; + } std::vector<unsigned char> vchRet = DecodeBase64(str.c_str(), pf_invalid); return std::string((const char*)vchRet.data(), vchRet.size()); } |