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

Git pushed a commit to branch master
in repository ffmpeg.

commit c46268660b4f306c53f81dac0cf7d11e4f443d27
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Tue Oct 13 05:52:20 2026 +0200
Commit:     michaelni <[email protected]>
CommitDate: Tue Oct 20 20:41:50 2026 +0000

    avformat/assenc: do not read the event beyond the packet
    
    Fixes: FJdNqUYeEkPS
    Fixes: wrong event text
    Fixes: out of array read
    Wrong event text Replicated through UnModified FFmpeg with plain output diff
    Out of array read Replicated through API with ASAN
    Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24659
    
    Found-by: Marton Balint <[email protected]>
    Suggested-by: Marton Balint <[email protected]>
---
 libavformat/assenc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/assenc.c b/libavformat/assenc.c
index b948203885..e121ceb632 100644
--- a/libavformat/assenc.c
+++ b/libavformat/assenc.c
@@ -155,15 +155,19 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 
     long int layer;
     int text_len;
-    char *p = pkt->data;
+    char *text = av_strndup(pkt->data, pkt->size);
+    char *p = text;
     int64_t start = pkt->pts;
     int64_t end   = start + pkt->duration;
     int hh1, mm1, ss1, ms1;
     int hh2, mm2, ss2, ms2;
     DialogueLine *dialogue = av_mallocz(sizeof(*dialogue));
 
-    if (!dialogue)
+    if (!text || !dialogue) {
+        av_free(text);
+        av_free(dialogue);
         return AVERROR(ENOMEM);
+    }
 
     dialogue->readorder = strtol(p, &p, 10);
     if (dialogue->readorder < ass->expected_readorder)
@@ -192,6 +196,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
     dialogue->line = 
av_asprintf("%s%ld,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%.*s",
                                  ass->ssa_mode ? "Marked=" : "",
                                  layer, hh1, mm1, ss1, ms1, hh2, mm2, ss2, 
ms2, text_len, p);
+    av_free(text);
     if (!dialogue->line) {
         av_free(dialogue);
         return AVERROR(ENOMEM);

-- 
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