mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02: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:
parent
d648b5120b
commit
a4377a0843
5 changed files with 17 additions and 15 deletions
|
|
@ -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(':'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue