| author | |
| committer | |
| log | c6044e6a109aa3a01eb9daadb13c6256b80e853c |
| tree | 0757f2b9f5b3834866e2b4622442e4b32a93793a |
| parent | 4465f34532491c3c185c3ee6008a00a8c907abf9 |
| signature | Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM |
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 |