diff options
author | Nikolai Vavilov <vvnicholas@gmail.com> | 2017-06-13 18:18:37 +0300 |
---|---|---|
committer | Nikolai Vavilov <vvnicholas@gmail.com> | 2017-06-16 19:09:50 +0300 |
commit | 64812f57287551016006d1e95b9e5812d2ce75fb (patch) | |
tree | 7b02d6a0a373254d59f76f6f920424a141abb600 /src/base64.h | |
parent | 00aac57df934b4727a3e6fc8cf70db40216f29ee (diff) | |
download | node-new-64812f57287551016006d1e95b9e5812d2ce75fb.tar.gz |
src: fix decoding base64 with whitespace
`max_i` should also include the characters that were just read by
`base64_decode_group_slow()`.
PR-URL: https://github.com/nodejs/node/pull/13660
Fixes: https://github.com/nodejs/node/issues/13636
Fixes: https://github.com/nodejs/node/issues/13657
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/base64.h')
-rw-r--r-- | src/base64.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/base64.h b/src/base64.h index 2e0f8e3858..89c6251ef8 100644 --- a/src/base64.h +++ b/src/base64.h @@ -99,10 +99,9 @@ size_t base64_decode_fast(char* const dst, const size_t dstlen, unbase64(src[i + 3]); // If MSB is set, input contains whitespace or is not valid base64. if (v & 0x80808080) { - const size_t old_i = i; if (!base64_decode_group_slow(dst, dstlen, src, srclen, &i, &k)) return k; - max_i = old_i + (srclen - i) / 4 * 4; // Align max_i again. + max_i = i + (srclen - i) / 4 * 4; // Align max_i again. } else { dst[k + 0] = ((v >> 22) & 0xFC) | ((v >> 20) & 0x03); dst[k + 1] = ((v >> 12) & 0xF0) | ((v >> 10) & 0x0F); |