diff mbox

[FFmpeg-devel] avformat/mov: Add check for per-sample IV size.

Message ID 20180612212620.231180-1-modmaker@google.com
State Accepted
Commit 4aba45ca1fece6be425d168c05aa3a7f9f05da36
Headers show

Commit Message

Jacob Trimble June 12, 2018, 9:26 p.m. UTC
Found by Chrome's ClusterFuzz: http://crbug.com/849062.

Signed-off-by: Jacob Trimble <modmaker@google.com>
---
 libavformat/mov.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer June 13, 2018, 2:33 p.m. UTC | #1
On Tue, Jun 12, 2018 at 02:26:20PM -0700, Jacob Trimble wrote:
> Found by Chrome's ClusterFuzz: http://crbug.com/849062.
> 
> Signed-off-by: Jacob Trimble <modmaker@google.com>
> ---
>  libavformat/mov.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

will apply

thanks

[...]
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2fca025889..5d9ffa69a3 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6273,8 +6273,13 @@  static int mov_read_tenc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             return AVERROR(ENOMEM);
     }
     sc->cenc.per_sample_iv_size = avio_r8(pb);
+    if (sc->cenc.per_sample_iv_size != 0 && sc->cenc.per_sample_iv_size != 8 &&
+        sc->cenc.per_sample_iv_size != 16) {
+        av_log(c->fc, AV_LOG_ERROR, "invalid per-sample IV size value\n");
+        return AVERROR_INVALIDDATA;
+    }
     if (avio_read(pb, sc->cenc.default_encrypted_sample->key_id, 16) != 16) {
-        av_log(c->fc, AV_LOG_ERROR, "failed to read the default key ID");
+        av_log(c->fc, AV_LOG_ERROR, "failed to read the default key ID\n");
         return AVERROR_INVALIDDATA;
     }
 
@@ -6286,7 +6291,7 @@  static int mov_read_tenc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         }
 
         if (avio_read(pb, sc->cenc.default_encrypted_sample->iv, iv_size) != iv_size) {
-            av_log(c->fc, AV_LOG_ERROR, "failed to read the default IV");
+            av_log(c->fc, AV_LOG_ERROR, "failed to read the default IV\n");
             return AVERROR_INVALIDDATA;
         }
     }