Closed Bouska closed 3 years ago
I believe this should be (pos + 2 < length_of_string)
instead of (pos + 2 < length_of_string - 1)
and
(pos + 3 < length_of_string)
instead of (pos + 3 < length_of_string - 1)
Used pos + 2 < length_of_string
to check for unpadded data.
You are right, < length_of_string
allows to check for the last non-NULL character. Somehow my tests with < length_of_string - 1
worked 🤔
Current code does not accept non padded data while the RFC2045 accepts non padded data. If non padded data is passed, the code will either throw
std::runtime_error: Input is not valid base64-encoded data.
when decoding the NULL terminator of the string or fail with a out of bound check.With proposed code, we check for either end of the string (for non padded data) or a padding character. I didn't check the performance, but I'm expecting a performance drop because of this additional check.
Fixes #24