mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-28 10:04:37 +08:00
avformat/flvenc: reject text packets too long for an AMF0 string
AV_CODEC_ID_TEXT packets are written as an AMF0 string, whose length is a 16-bit field. For text over 65535 bytes the length wrapped (e.g. 4464 for 70000 bytes) while the whole text was written, so readers misparse the onTextData tag. Fail on such packets before writing the tag. Found while reviewing the metadata length fix for FLV. Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
This commit is contained in:
1 parent
d20d75cb9b
commit
5993347a1b
1 file changed
+6
@@ -1280,6 +1280,12 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
/* the text is written as an AMF0 string with a 16-bit length */
|
||||
if (par->codec_id == AV_CODEC_ID_TEXT &&
|
||||
strlen((const char *)pkt->data) > UINT16_MAX) {
|
||||
av_log(s, AV_LOG_ERROR, "Text packet is too long for FLV\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ts = pkt->dts;
|
||||
|
||||
|
||||
Reference in new issue
Block a user