Commit f0158e6f authored by Stefano Sabatini's avatar Stefano Sabatini

lavf/flvenc: fail in case the muxed packet is too big

Avoid the creation of files which cannot be successfully decoded by
ffmpeg, for example generated with:
ffmpeg -f lavfi -i sine -af "aselect='not(between(t,100,500))',aresample=min_comp=0.001:min_hard_comp=0.100000" -acodec pcm_s16le -t 1000 -y out_audio.flv
parent 4f4de7f4
......@@ -548,6 +548,12 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
if (sc->last_ts < ts)
sc->last_ts = ts;
if (size + flags_size >= 1<<24) {
av_log(s, AV_LOG_ERROR, "Too large packet with size %u >= %u\n",
size + flags_size, 1<<24);
return AVERROR(EINVAL);
}
avio_wb24(pb, size + flags_size);
avio_wb24(pb, ts & 0xFFFFFF);
avio_w8(pb, (ts >> 24) & 0x7F); // timestamps are 32 bits _signed_
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment