[FFmpeg-devel] [PATCH] Optimize output buffer size check in base64 decode.
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Fri Jan 20 22:14:49 CET 2012
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
libavutil/base64.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/libavutil/base64.c b/libavutil/base64.c
index 6843a53..9eba58b 100644
--- a/libavutil/base64.c
+++ b/libavutil/base64.c
@@ -47,6 +47,7 @@ int av_base64_decode(uint8_t *out, const char *in, int out_size)
{
int i, v;
uint8_t *dst = out;
+ uint8_t *end = out + out_size;
v = 0;
for (i = 0; ; i++) {
@@ -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;
v = (v << 6) + map2[index];
if (i & 3) {
- if (dst - out < out_size) {
+ if (dst < end) {
*dst++ = v >> (6 - 2 * (i & 3));
}
}
--
1.7.8.3
More information about the ffmpeg-devel
mailing list