]> git.sesse.net Git - ffmpeg/blobdiff - fftools/ffmpeg_opt.c
avformat/matroska: Move mime_tag lists to matroskadec
[ffmpeg] / fftools / ffmpeg_opt.c
index 93b3d96205de3845bfd67ecba5f2c214707bdad5..680f0f1dfb73e55779bafed6a55a3f18a6be1edf 100644 (file)
@@ -2432,12 +2432,14 @@ loop_end:
                    o->attachments[i]);
             exit_program(1);
         }
-        if (!(attachment = av_malloc(len))) {
-            av_log(NULL, AV_LOG_FATAL, "Attachment %s too large to fit into memory.\n",
+        if (len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE ||
+            !(attachment = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE))) {
+            av_log(NULL, AV_LOG_FATAL, "Attachment %s too large.\n",
                    o->attachments[i]);
             exit_program(1);
         }
         avio_read(pb, attachment, len);
+        memset(attachment + len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
         ost = new_attachment_stream(o, oc, -1);
         ost->stream_copy               = 0;