Commit 6af4c981 authored by Reimar Döffinger's avatar Reimar Döffinger

Optimize output buffer size check in base64 decode.

Signed-off-by: 's avatarReimar Döffinger <Reimar.Doeffinger@gmx.de>
parent 686ba5f4
...@@ -47,6 +47,7 @@ int av_base64_decode(uint8_t *out, const char *in, int out_size) ...@@ -47,6 +47,7 @@ int av_base64_decode(uint8_t *out, const char *in, int out_size)
{ {
int i, v; int i, v;
uint8_t *dst = out; uint8_t *dst = out;
uint8_t *end = out + out_size;
v = 0; v = 0;
for (i = 0; ; i++) { for (i = 0; ; i++) {
...@@ -55,7 +56,7 @@ int av_base64_decode(uint8_t *out, const char *in, int out_size) ...@@ -55,7 +56,7 @@ int av_base64_decode(uint8_t *out, const char *in, int out_size)
return in[i] && in[i] != '=' ? -1 : dst - out; return in[i] && in[i] != '=' ? -1 : dst - out;
v = (v << 6) + map2[index]; v = (v << 6) + map2[index];
if (i & 3) { if (i & 3) {
if (dst - out < out_size) { if (dst < end) {
*dst++ = v >> (6 - 2 * (i & 3)); *dst++ = v >> (6 - 2 * (i & 3));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment