[FFmpeg-devel] [PATCH 7/7] avformat/sdp: Actually check that parameter set is SPS

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Thu Jul 9 13:35:42 EEST 2020


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavformat/sdp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index aa0569cd0d..023c88a583 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -24,6 +24,7 @@
 #include "libavutil/dict.h"
 #include "libavutil/parseutils.h"
 #include "libavutil/opt.h"
+#include "libavcodec/h264.h"
 #include "libavcodec/xiph.h"
 #include "libavcodec/mpeg4audio.h"
 #include "avformat.h"
@@ -161,7 +162,7 @@ static char *extradata2psets(AVFormatContext *s, AVCodecParameters *par)
     uint8_t *extradata = par->extradata;
     int extradata_size = par->extradata_size;
     uint8_t *tmpbuf = NULL;
-    const uint8_t *sps = NULL, *sps_end;
+    const uint8_t *sps = NULL;
 
     if (par->extradata_size > MAX_EXTRADATA_SIZE) {
         av_log(s, AV_LOG_ERROR, "Too much extradata!\n");
@@ -199,10 +200,9 @@ static char *extradata2psets(AVFormatContext *s, AVCodecParameters *par)
             *p = ',';
             p++;
         }
-        if (!sps) {
+        if (nal_type == H264_NAL_SPS && !sps && r1 - r >= 4)
             sps = r;
-            sps_end = r1;
-        }
+
         if (!av_base64_encode(p, MAX_PSET_SIZE - (p - psets), r, r1 - r)) {
             av_log(s, AV_LOG_ERROR, "Cannot Base64-encode %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER"!\n", MAX_PSET_SIZE - (p - psets), r1 - r);
             av_free(psets);
@@ -213,7 +213,7 @@ static char *extradata2psets(AVFormatContext *s, AVCodecParameters *par)
         p += strlen(p);
         r = r1;
     }
-    if (sps && sps_end - sps >= 4 && p - psets <= MAX_PSET_SIZE - strlen(profile_string) - 7) {
+    if (sps && p - psets <= MAX_PSET_SIZE - strlen(profile_string) - 7) {
         memcpy(p, profile_string, strlen(profile_string));
         p += strlen(p);
         ff_data_to_hex(p, sps + 1, 3, 0);
-- 
2.20.1



More information about the ffmpeg-devel mailing list