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

Submitted by lance.lmwang@gmail.com on Aug. 10, 2019, 3:53 p.m.

Details

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

Commit Message

lance.lmwang@gmail.com Aug. 10, 2019, 3:53 p.m.
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

lance.lmwang@gmail.com Aug. 17, 2019, 2:58 p.m.
ping, please help to merge the code if it's OK.

On Sat, Aug 10, 2019 at 11:53:25PM +0800, lance.lmwang@gmail.com wrote:
> 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 68ce9a8..4b18032 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_ERROR, "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_ERROR, "invalid data");
> +        return;
> +    }
>      av_log(ctx, AV_LOG_INFO, "Content Light Level Metadata, "
>             "MaxCLL=%d, MaxFALL=%d",
>             metadata->MaxCLL, metadata->MaxFALL);
> -- 
> 2.6.4
>
James Almer Aug. 17, 2019, 5:50 p.m.
On 8/10/2019 12:53 PM, lance.lmwang@gmail.com wrote:
> 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 68ce9a8..4b18032 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_ERROR, "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_ERROR, "invalid data");
> +        return;
> +    }
>      av_log(ctx, AV_LOG_INFO, "Content Light Level Metadata, "
>             "MaxCLL=%d, MaxFALL=%d",
>             metadata->MaxCLL, metadata->MaxFALL);

No, the size of both structs is not part of the ABI.

Patch hide | download patch | download mbox

diff --git a/libavformat/dump.c b/libavformat/dump.c
index 68ce9a8..4b18032 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_ERROR, "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_ERROR, "invalid data");
+        return;
+    }
     av_log(ctx, AV_LOG_INFO, "Content Light Level Metadata, "
            "MaxCLL=%d, MaxFALL=%d",
            metadata->MaxCLL, metadata->MaxFALL);