Fix decode issue #2
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In base64_decode_block(), step_b & step_c have a bug in that they will cause bits of the next byte to be written even though there are no more bytes in the encoded data. This adds an additional check for more encoded data before writing the additional bits to the next byte.
Additional Information:
The encoder encodes data in 3 byte groups into 4 Base64 characters. If the data being encoded is not a multiple of 3 bytes then the encoder will append = characters in the Base64 data. Therefore you may end up with Base64 data that contains one or more trailing = characters.
When decoding the data the = characters are ignored however the bug in the decoder automatically writes any remaining bits in the current step into the next byte position even if the encoded data has no more bits. Which causes bits outside of the actual encoded data to be modified unexpectedly.