diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2019-12-16 09:00:20 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2019-12-16 09:04:36 +0000 |
commit | a6fc26da55dea3b76bd89fbbca24ded170238674 (patch) | |
tree | 922f1fc5d75cac77a98412608a7321166517af99 /src/util | |
parent | 93cc18b0f6fa5fa8144079a4f51904d8b3087e94 (diff) |
util: Don't allow DecodeBase32(...) 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 dfd8961cb7..31719cd975 100644 --- a/src/util/strencodings.cpp +++ b/src/util/strencodings.cpp @@ -266,6 +266,12 @@ std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid) std::string DecodeBase32(const std::string& str, bool* pf_invalid) { + if (!ValidAsCString(str)) { + if (pf_invalid) { + *pf_invalid = true; + } + return {}; + } std::vector<unsigned char> vchRet = DecodeBase32(str.c_str(), pf_invalid); return std::string((const char*)vchRet.data(), vchRet.size()); } |