diff mbox

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

Message ID 20190810145907.12326-1-lance.lmwang@gmail.com
State New
Headers show

Commit Message

Lance Wang Aug. 10, 2019, 2:59 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

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

Comments

Carl Eugen Hoyos Aug. 10, 2019, 3:14 p.m. UTC | #1
Am Sa., 10. Aug. 2019 um 16:59 Uhr schrieb <lance.lmwang@gmail.com>:
>
> From: Limin Wang <lance.lmwang@gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang@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");

Why is this AV_LOG_INFO and not WARNING or ERROR?

Carl Eugen
Lance Wang Aug. 10, 2019, 3:38 p.m. UTC | #2
On Sat, Aug 10, 2019 at 05:14:18PM +0200, Carl Eugen Hoyos wrote:
> Am Sa., 10. Aug. 2019 um 16:59 Uhr schrieb <lance.lmwang@gmail.com>:
> >
> > From: Limin Wang <lance.lmwang@gmail.com>
> >
> > Signed-off-by: Limin Wang <lance.lmwang@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");
> 
> Why is this AV_LOG_INFO and not WARNING or ERROR?
It's for keep the style consistent. In the dump.c, all such error is
used as AV_LOG_INFO. If need, I'll submit a patch to change INFO to ERROR first? 


> 
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox

Patch

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