diff mbox

[FFmpeg-devel,3/4] avcodec/iff: Check for overlap in cmap_read_palette()

Message ID 20190821221855.1844-3-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Aug. 21, 2019, 10:18 p.m. UTC
Fixes: undefined mempcpy() use
Fixes: 16302/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5678750575886336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/iff.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Moritz Barsnick Aug. 22, 2019, 7:32 a.m. UTC | #1
On Thu, Aug 22, 2019 at 00:18:54 +0200, Michael Niedermayer wrote:

Nits:

> Fixes: undefined mempcpy() use

memcpy

> +            avpriv_request_sample(avctx, "overlaping mask");

overlapping

Cheers,
Moritz
Michael Niedermayer Aug. 22, 2019, 3:56 p.m. UTC | #2
On Thu, Aug 22, 2019 at 09:32:39AM +0200, Moritz Barsnick wrote:
> On Thu, Aug 22, 2019 at 00:18:54 +0200, Michael Niedermayer wrote:
> 
> Nits:
> 
> > Fixes: undefined mempcpy() use
> 
> memcpy
> 
> > +            avpriv_request_sample(avctx, "overlaping mask");
> 
> overlapping

locally corrected

[...]
Michael Niedermayer Sept. 5, 2019, 5:27 p.m. UTC | #3
On Thu, Aug 22, 2019 at 05:56:14PM +0200, Michael Niedermayer wrote:
> On Thu, Aug 22, 2019 at 09:32:39AM +0200, Moritz Barsnick wrote:
> > On Thu, Aug 22, 2019 at 00:18:54 +0200, Michael Niedermayer wrote:
> > 
> > Nits:
> > 
> > > Fixes: undefined mempcpy() use
> > 
> > memcpy
> > 
> > > +            avpriv_request_sample(avctx, "overlaping mask");
> > 
> > overlapping
> 
> locally corrected

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index fc7bfad731..f612399daa 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -180,6 +180,10 @@  static int cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
             pal[i] = 0xFF000000 | gray2rgb((i * 255) >> avctx->bits_per_coded_sample);
     }
     if (s->masking == MASK_HAS_MASK) {
+        if ((1 << avctx->bits_per_coded_sample) < count) {
+            avpriv_request_sample(avctx, "overlaping mask");
+            return AVERROR_PATCHWELCOME;
+        }
         memcpy(pal + (1 << avctx->bits_per_coded_sample), pal, count * 4);
         for (i = 0; i < count; i++)
             pal[i] &= 0xFFFFFF;