Skip to content

Commit a6fc26d

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

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
@@ -266,6 +266,12 @@ std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid)
266266

267267
std::string DecodeBase32(const std::string& str, bool* pf_invalid)
268268
{
269+
if (!ValidAsCString(str)) {
270+
if (pf_invalid) {
271+
*pf_invalid = true;
272+
}
273+
return {};
274+
}
269275
std::vector<unsigned char> vchRet = DecodeBase32(str.c_str(), pf_invalid);
270276
return std::string((const char*)vchRet.data(), vchRet.size());
271277
}

0 commit comments

Comments
 (0)