Skip to content

Commit 93cc18b

Browse files
util: Don't allow DecodeBase64(...) of strings with embedded NUL characters
1 parent ccc53e4 commit 93cc18b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/util/strencodings.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid)
191191

192192
std::string DecodeBase64(const std::string& str, bool* pf_invalid)
193193
{
194+
if (!ValidAsCString(str)) {
195+
if (pf_invalid) {
196+
*pf_invalid = true;
197+
}
198+
return {};
199+
}
194200
std::vector<unsigned char> vchRet = DecodeBase64(str.c_str(), pf_invalid);
195201
return std::string((const char*)vchRet.data(), vchRet.size());
196202
}

0 commit comments

Comments
 (0)