[FFmpeg-cvslog] avutil/tests/base64: Check with too short output array

Michael Niedermayer git at videolan.org
Wed May 22 23:15:50 EEST 2024


ffmpeg | branch: release/7.0 | Michael Niedermayer <michael at niedermayer.cc> | Sat May 11 03:14:16 2024 +0200| [9eb6558fa91e2f3584769551dc396e189564f56d] | committer: Michael Niedermayer

avutil/tests/base64: Check with too short output array

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

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

 libavutil/tests/base64.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavutil/tests/base64.c b/libavutil/tests/base64.c
index 400e01cefe..66d0fdc1fc 100644
--- a/libavutil/tests/base64.c
+++ b/libavutil/tests/base64.c
@@ -64,6 +64,16 @@ static int test_encode_decode(const uint8_t *data, unsigned int data_size,
         printf("Failed: decode to NULL buffer\n");
         return 1;
     }
+    if (data_size > 0 && (data2_size = av_base64_decode(data2, encoded, data_size - 1)) != data_size - 1) {
+        printf("Failed: out of array write\n"
+               "Encoded:\n%s\n", encoded);
+        return 1;
+    }
+    if (data_size > 1 && (data2_size = av_base64_decode(data2, encoded, data_size - 2)) != data_size - 2) {
+        printf("Failed: out of array write\n"
+               "Encoded:\n%s\n", encoded);
+        return 1;
+    }
     if (strlen(encoded)) {
         char *end = strchr(encoded, '=');
         if (!end)



More information about the ffmpeg-cvslog mailing list