[FFmpeg-devel] [PATCH 2/2] [monvenc] Add extra padding when allocating trk->vos_data

Thierry Foucu tfoucu at gmail.com
Thu Sep 26 20:58:53 EEST 2019


trk->vos_data is mostly used to store the extradata from the codec.
Most encoder when storing their extradata, are allocating with padding.
But the current code was ignoring the padding, which could causes
heap-buffer-overflow
---
 libavformat/movenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index e095af0972..11cf1a13a9 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5378,7 +5378,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
         !TAG_IS_AVCI(trk->tag) &&
         (par->codec_id != AV_CODEC_ID_DNXHD)) {
         trk->vos_len  = par->extradata_size;
-        trk->vos_data = av_malloc(trk->vos_len);
+        trk->vos_data = av_mallocz(trk->vos_len + AV_INPUT_BUFFER_PADDING_SIZE);
         if (!trk->vos_data) {
             ret = AVERROR(ENOMEM);
             goto err;
-- 
2.23.0.444.g18eeb5a265-goog



More information about the ffmpeg-devel mailing list