mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
util: Don't allow DecodeBase32(...) of strings with embedded NUL characters
This commit is contained in:
parent
93cc18b0f6
commit
a6fc26da55
1 changed files with 6 additions and 0 deletions
|
@ -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)
|
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);
|
std::vector<unsigned char> vchRet = DecodeBase32(str.c_str(), pf_invalid);
|
||||||
return std::string((const char*)vchRet.data(), vchRet.size());
|
return std::string((const char*)vchRet.data(), vchRet.size());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue