Fix a corner case when decoding base64:

Under some corner cases, the base64 decoder would not allocate
enough memory, which could result in spurious errors.

Acknowledgements:
Ripple thanks Guido Vranken for originally noticing this issue
and responsibly disclosing it to Ripple.

Bug Bounties and Responsible Disclosures:
We welcome reviews of the rippled code and urge researchers
to responsibly disclose any issues that they may find. For
more on Ripple's Bug Bounty program, please visit:
https://ripple.com/bug-bounty
This commit is contained in:
Nik Bougalis
2018-06-04 16:34:10 -07:00
parent 00df097e5f
commit 0439dcfa7a

View File

@@ -96,8 +96,7 @@ inline
std::size_t constexpr
decoded_size(std::size_t n)
{
return n / 4 * 3; // requires n&3==0, smaller
//return 3 * n / 4;
return ((n / 4) * 3) + 2;
}
/** Encode a series of octets as a padded, base64 string.