mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
Reject incorrect base64 in HTTP auth
In addition, to make sure that no call site ignores the invalid decoding status, make the pf_invalid argument mandatory.
This commit is contained in:
@@ -132,7 +132,9 @@ static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUserna
|
||||
if (strAuth.substr(0, 6) != "Basic ")
|
||||
return false;
|
||||
std::string strUserPass64 = TrimString(strAuth.substr(6));
|
||||
std::string strUserPass = DecodeBase64(strUserPass64);
|
||||
bool invalid;
|
||||
std::string strUserPass = DecodeBase64(strUserPass64, &invalid);
|
||||
if (invalid) return false;
|
||||
|
||||
if (strUserPass.find(':') != std::string::npos)
|
||||
strAuthUsernameOut = strUserPass.substr(0, strUserPass.find(':'));
|
||||
|
||||
Reference in New Issue
Block a user