From 6d7e29620578a4a4116aa8d014378b1abefcab65 Mon Sep 17 00:00:00 2001 From: Leo Ma Date: Tue, 7 Mar 2017 16:11:18 +0800 Subject: [PATCH] Fix FLV tag buffer overflow Add header size in encoded stream Signed-off-by: Leo Ma --- library/src/main/java/net/ossrs/yasea/SrsFlvMuxer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/net/ossrs/yasea/SrsFlvMuxer.java b/library/src/main/java/net/ossrs/yasea/SrsFlvMuxer.java index 0c53efd..3e762b8 100644 --- a/library/src/main/java/net/ossrs/yasea/SrsFlvMuxer.java +++ b/library/src/main/java/net/ossrs/yasea/SrsFlvMuxer.java @@ -604,7 +604,7 @@ public class SrsFlvMuxer { // 1bytes, AVCPacketType // 3bytes, CompositionTime, the cts. // @see: E.4.3 Video Tags, video_file_format_spec_v10_1.pdf, page 78 - SrsAllocator.Allocation allocation = mVideoAllocator.allocate(size); + SrsAllocator.Allocation allocation = mVideoAllocator.allocate(size + 5); // @see: E.4.3 Video Tags, video_file_format_spec_v10_1.pdf, page 78 // Frame Type, Type of video frame. @@ -754,7 +754,7 @@ public class SrsFlvMuxer { int pts = (int)(bi.presentationTimeUs / 1000); int dts = pts; - audio_tag = mAudioAllocator.allocate(bi.size); + audio_tag = mAudioAllocator.allocate(bi.size + 2); byte aac_packet_type = 1; // 1 = AAC raw if (!aac_specific_config_got) { // @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf