Re: [FFmpeg-devel] [PATCH 1/4] avformat/vividas: Check for input length in get_v()

2019-07-08 Thread Michael Niedermayer
On Thu, Jun 27, 2019 at 02:35:30AM +0200, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 
> 15286/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5658245101780992
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/vividas.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/4] avformat/vividas: Check for input length in get_v()

2019-06-26 Thread Michael Niedermayer
Fixes: out of array read
Fixes: 
15286/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5658245101780992

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/vividas.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index 753328245d..350c7aa70a 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -178,12 +178,13 @@ static void decode_block(uint8_t *src, uint8_t *dest, 
unsigned size,
 }
 }
 
-static uint32_t get_v(uint8_t *p)
+static uint32_t get_v(uint8_t *p, int len)
 {
 uint32_t v = 0;
+const uint8_t *end = p + len;
 
 do {
-if (v >= UINT_MAX / 128 - *p)
+if (p >= end || v >= UINT_MAX / 128 - *p)
 return v;
 v <<= 7;
 v += *p & 0x7f;
@@ -204,7 +205,7 @@ static uint8_t *read_vblock(AVIOContext *src, uint32_t 
*size,
 
 decode_block(tmp, tmp, 4, key, k2, align);
 
-n = get_v(tmp);
+n = get_v(tmp, 4);
 if (n < 4)
 return NULL;
 
@@ -241,13 +242,13 @@ static uint8_t *read_sb_block(AVIOContext *src, unsigned 
*size,
 k2 = *key;
 decode_block(ibuf, sbuf, 8, *key, &k2, 0);
 
-n = get_v(sbuf+2);
+n = get_v(sbuf+2, 6);
 
 if (sbuf[0] != 'S' || sbuf[1] != 'B' || (expected_size>0 && n != 
expected_size)) {
 uint32_t tmpkey = recover_key(ibuf, expected_size);
 k2 = tmpkey;
 decode_block(ibuf, sbuf, 8, tmpkey, &k2, 0);
-n = get_v(sbuf+2);
+n = get_v(sbuf+2, 6);
 if (sbuf[0] != 'S' || sbuf[1] != 'B' || expected_size != n)
 return NULL;
 *key = tmpkey;
-- 
2.22.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".