This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit e784547477d115c88470a5be813cf68362b508f8
Author:     Marton Balint <[email protected]>
AuthorDate: Sat Mar 13 22:33:39 2021 +0100
Commit:     michaelni <[email protected]>
CommitDate: Tue Oct 20 20:41:50 2026 +0000

    avcodec/samidec: do not overread if zero padding is missing
    
    Fixes: a3ewdvDE2QSe
    Fixes: out of array read
    Out of array read Replicated through API with ASAN
    
    Signed-off-by: Marton Balint <[email protected]>
---
 libavcodec/samidec.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c
index d8a7624bc3..252fb04179 100644
--- a/libavcodec/samidec.c
+++ b/libavcodec/samidec.c
@@ -41,12 +41,12 @@ typedef struct {
     int readorder;
 } SAMIContext;
 
-static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
+static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src, 
size_t size)
 {
     SAMIContext *sami = avctx->priv_data;
     int ret = 0;
     char *tag = NULL;
-    char *dupsrc = av_strdup(src);
+    char *dupsrc = av_strndup(src, size);
     char *p = dupsrc;
     AVBPrint *dst_content = &sami->encoded_content;
     AVBPrint *dst_source = &sami->encoded_source;
@@ -137,11 +137,10 @@ end:
 static int sami_decode_frame(AVCodecContext *avctx, AVSubtitle *sub,
                              int *got_sub_ptr, const AVPacket *avpkt)
 {
-    const char *ptr = avpkt->data;
     SAMIContext *sami = avctx->priv_data;
 
-    if (ptr && avpkt->size > 0) {
-        int ret = sami_paragraph_to_ass(avctx, ptr);
+    if (avpkt->data && avpkt->size > 0) {
+        int ret = sami_paragraph_to_ass(avctx, avpkt->data, avpkt->size);
         if (ret < 0)
             return ret;
         // TODO: pass escaped sami->encoded_source.str as source

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to