mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-16 11:53:07 +02:00
util: Don't allow DecodeBase64(...) of strings with embedded NUL characters
This commit is contained in:
parent
ccc53e43c5
commit
93cc18b0f6
@ -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)
|
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);
|
std::vector<unsigned char> vchRet = DecodeBase64(str.c_str(), pf_invalid);
|
||||||
return std::string((const char*)vchRet.data(), vchRet.size());
|
return std::string((const char*)vchRet.data(), vchRet.size());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user