Commit e00aa4bad3 for ffmpeg
commit e00aa4bad39f76e9428d03ee5537f5b2b8c2c6e2
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu Oct 8 01:53:17 2026 +0200
avformat/mpegtsenc: Do not copy extradata that does not exist
For streams without extradata memcpy() was called with a NULL source.
Fixes: 5M151mE1kuw5
memcpy() from NULL Replicated through UnModified FFmpeg with UBSAN
Found while testing the fix for the security report AISLE-2026-0111-00391
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 89d64c1f1c..7d04ad03e5 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1906,7 +1906,8 @@ static uint8_t *h26x_prefix_aud(const uint8_t *aud, const int aud_size,
return NULL;
AV_WB32(data, 0x00000001);
memcpy(data + sz, aud, aud_size);
- memcpy(data + sz + aud_size, extra_data, extra_size);
+ if (extra_size)
+ memcpy(data + sz + aud_size, extra_data, extra_size);
memcpy(data + sz + aud_size + extra_size, pkt->data, pkt->size);
*size = pkt->size + sz + aud_size + extra_size;
return data;