[FFmpeg-cvslog] libavutil/base64: Try not to write over the array end

Michael Niedermayer git at videolan.org
Sun Jan 5 01:27:25 EET 2025


ffmpeg | branch: release/2.8 | Michael Niedermayer <michael at niedermayer.cc> | Sat May 11 03:13:17 2024 +0200| [c13f25a0de897884986f9ac77214d8ae92c4c716] | committer: Michael Niedermayer

libavutil/base64: Try not to write over the array end

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 2d216566f258badd07bc58de1e089b6e4175dc46)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c13f25a0de897884986f9ac77214d8ae92c4c716
---

 libavutil/base64.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavutil/base64.c b/libavutil/base64.c
index 03ebce8b80..160d9bc9c4 100644
--- a/libavutil/base64.c
+++ b/libavutil/base64.c
@@ -120,10 +120,12 @@ int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
     }
 
 out3:
-    *dst++ = v >> 10;
+    if (end - dst)
+        *dst++ = v >> 10;
     v <<= 2;
 out2:
-    *dst++ = v >> 4;
+    if (end - dst)
+        *dst++ = v >> 4;
 out1:
 out0:
     return bits & 1 ? AVERROR_INVALIDDATA : dst - out;



More information about the ffmpeg-cvslog mailing list