Re: [FFmpeg-devel] [PATCH 2/3] avformat/mov: Do not deallocate heif_item in a input dependant way

2024-03-26 Thread Michael Niedermayer
On Mon, Mar 25, 2024 at 10:22:19PM -0300, James Almer wrote:
> On 3/22/2024 8:08 PM, Michael Niedermayer wrote:
> > Fixes: out of array access
> > Fixes: 
> > 67070/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5685384082161664
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >   libavformat/mov.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index f954b924a0..a87ce5cefe 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -8077,7 +8077,7 @@ static int mov_read_iloc(MOVContext *c, AVIOContext 
> > *pb, MOVAtom atom)
> >   }
> >   item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
> > -heif_item = av_realloc_array(c->heif_item, item_count, 
> > sizeof(*c->heif_item));
> > +heif_item = av_realloc_array(c->heif_item, FFMAX(item_count, 
> > c->nb_heif_item), sizeof(*c->heif_item));
> >   if (!heif_item)
> >   return AVERROR(ENOMEM);
> >   c->heif_item = heif_item;
> > @@ -8202,7 +8202,7 @@ static int mov_read_iinf(MOVContext *c, AVIOContext 
> > *pb, MOVAtom atom)
> >   avio_rb24(pb);  // flags.
> >   entry_count = version ? avio_rb32(pb) : avio_rb16(pb);
> > -heif_item = av_realloc_array(c->heif_item, entry_count, 
> > sizeof(*c->heif_item));
> > +heif_item = av_realloc_array(c->heif_item, FFMAX(entry_count, 
> > c->nb_heif_item), sizeof(*c->heif_item));
> >   if (!heif_item)
> >   return AVERROR(ENOMEM);
> >   c->heif_item = heif_item;
> 
> LGTM.

will apply

thx

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

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


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".


Re: [FFmpeg-devel] [PATCH 2/3] avformat/mov: Do not deallocate heif_item in a input dependant way

2024-03-25 Thread James Almer

On 3/22/2024 8:08 PM, Michael Niedermayer wrote:

Fixes: out of array access
Fixes: 
67070/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5685384082161664

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f954b924a0..a87ce5cefe 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8077,7 +8077,7 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
  }
  item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
  
-heif_item = av_realloc_array(c->heif_item, item_count, sizeof(*c->heif_item));

+heif_item = av_realloc_array(c->heif_item, FFMAX(item_count, 
c->nb_heif_item), sizeof(*c->heif_item));
  if (!heif_item)
  return AVERROR(ENOMEM);
  c->heif_item = heif_item;
@@ -8202,7 +8202,7 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
  avio_rb24(pb);  // flags.
  entry_count = version ? avio_rb32(pb) : avio_rb16(pb);
  
-heif_item = av_realloc_array(c->heif_item, entry_count, sizeof(*c->heif_item));

+heif_item = av_realloc_array(c->heif_item, FFMAX(entry_count, 
c->nb_heif_item), sizeof(*c->heif_item));
  if (!heif_item)
  return AVERROR(ENOMEM);
  c->heif_item = heif_item;


LGTM.
___
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 2/3] avformat/mov: Do not deallocate heif_item in a input dependant way

2024-03-22 Thread Michael Niedermayer
Fixes: out of array access
Fixes: 
67070/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5685384082161664

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f954b924a0..a87ce5cefe 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8077,7 +8077,7 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 }
 item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
 
-heif_item = av_realloc_array(c->heif_item, item_count, 
sizeof(*c->heif_item));
+heif_item = av_realloc_array(c->heif_item, FFMAX(item_count, 
c->nb_heif_item), sizeof(*c->heif_item));
 if (!heif_item)
 return AVERROR(ENOMEM);
 c->heif_item = heif_item;
@@ -8202,7 +8202,7 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 avio_rb24(pb);  // flags.
 entry_count = version ? avio_rb32(pb) : avio_rb16(pb);
 
-heif_item = av_realloc_array(c->heif_item, entry_count, 
sizeof(*c->heif_item));
+heif_item = av_realloc_array(c->heif_item, FFMAX(entry_count, 
c->nb_heif_item), sizeof(*c->heif_item));
 if (!heif_item)
 return AVERROR(ENOMEM);
 c->heif_item = heif_item;
-- 
2.17.1

___
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".