[FFmpeg-devel] [PATCH v1] lavf/dump: add the valid check for consistent

lance.lmwang at gmail.com lance.lmwang at gmail.com
Sat Aug 10 17:59:07 EEST 2019


From: Limin Wang <lance.lmwang at gmail.com>

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 libavformat/dump.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavformat/dump.c b/libavformat/dump.c
index 1c44656..d3c0299 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -328,6 +328,11 @@ static void dump_cpb(void *ctx, AVPacketSideData *sd)
 
 static void dump_mastering_display_metadata(void *ctx, AVPacketSideData* sd) {
     AVMasteringDisplayMetadata* metadata = (AVMasteringDisplayMetadata*)sd->data;
+
+    if (sd->size < sizeof(*metadata)) {
+        av_log(ctx, AV_LOG_INFO, "invalid data");
+        return;
+    }
     av_log(ctx, AV_LOG_INFO, "Mastering Display Metadata, "
            "has_primaries:%d has_luminance:%d "
            "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) "
@@ -346,6 +351,11 @@ static void dump_mastering_display_metadata(void *ctx, AVPacketSideData* sd) {
 static void dump_content_light_metadata(void *ctx, AVPacketSideData* sd)
 {
     AVContentLightMetadata* metadata = (AVContentLightMetadata*)sd->data;
+
+    if (sd->size < sizeof(*metadata)) {
+        av_log(ctx, AV_LOG_INFO, "invalid data");
+        return;
+    }
     av_log(ctx, AV_LOG_INFO, "Content Light Level Metadata, "
            "MaxCLL=%d, MaxFALL=%d",
            metadata->MaxCLL, metadata->MaxFALL);
-- 
2.6.4



More information about the ffmpeg-devel mailing list