| author | |
| committer | |
| log | fc9184e652990545e3b00b04852eff3e522538e1 |
| tree | 92cd8a07e530655129937bdf94c1249def22df2c |
| parent | 54460688aeb62584186e2fd3cb8998a8fa349c09 |
First, the correct length for decoding should be computed with
/4*3 , not the other way round as when encoding.
But also, without padding, a string such as "Zg" is valid base64
(here, it's the character 'f', padded base64 would be "Zg==").
decodedLenUpperBound() returned 0 instead of 1 in that example.
Correctly fix the computation of the upper bound.1 files changed, 1 insertions(+), 1 deletions(-)
lib/std/crypto/codecs/base64_hex_ct.zig+1-1| ... | ... | @@ -261,7 +261,7 @@ pub const base64 = struct { |
| 261 | 261 | |
| 262 | 262 | /// Returns the maximum possible decoded size for a given input length after skipping ignored characters. |
| 263 | 263 | pub fn decodedLenUpperBound(b64_len: usize) usize { |
| 264 | return b64_len / 3 * 4; | |
| 264 | return b64_len / 4 * 3 + (b64_len % 4) * 3 / 4; | |
| 265 | 265 | } |
| 266 | 266 | }; |
| 267 | 267 |