diff mbox series

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

Message ID 20200709103542.19909-7-andreas.rheinhardt@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/7] avformat/avc: Fix undefined shift and assert when reading exp-golomb num
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt July 9, 2020, 10:35 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/sdp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

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);