[FFmpeg-devel] [PATCH v2] avformat/vqf: Propagate errors from add_metadata()

Michael Niedermayer michael at niedermayer.cc
Tue Jan 21 20:02:06 EET 2025


On Wed, Jan 01, 2025 at 07:53:27PM +0100, Alexander Strasser via ffmpeg-devel wrote:
> On 2025-01-01 06:15 +0100, Michael Niedermayer wrote:
> > Suggested-by: Marton Balint <cus at passwd.hu>
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> >  libavformat/vqf.c | 21 ++++++++++++++-------
> >  1 file changed, 14 insertions(+), 7 deletions(-)
> >
> > diff --git a/libavformat/vqf.c b/libavformat/vqf.c
> > index 79deb33744b..58b1546f531 100644
> > --- a/libavformat/vqf.c
> > +++ b/libavformat/vqf.c
> > @@ -51,23 +51,28 @@ static int vqf_probe(const AVProbeData *probe_packet)
> >      return AVPROBE_SCORE_EXTENSION;
> >  }
> >
> > -static void add_metadata(AVFormatContext *s, uint32_t tag,
> > +static int add_metadata(AVFormatContext *s, uint32_t tag,
> >                           unsigned int tag_len, unsigned int remaining)
> >  {
> >      int len = FFMIN(tag_len, remaining);
> >      char *buf, key[5] = {0};
> > +    int ret;
> >
> >      if (len == UINT_MAX)
> > -        return;
> > +        return AVERROR_INVALIDDATA;
> >
> >      buf = av_malloc(len+1);
> >      if (!buf)
> > -        return;
> > -    if (len != avio_read(s->pb, buf, len))
> > -        return;
> > +        return AVERROR(ENOMEM);
> > +
> > +    ret = avio_read(s->pb, buf, len);
> > +    if (ret < 0)
> > +        return ret;
> > +    if (len != ret)
> > +        return AVERROR_INVALIDDATA;
> >      buf[len] = 0;
> >      AV_WL32(key, tag);
> > -    av_dict_set(&s->metadata, key, buf, AV_DICT_DONT_STRDUP_VAL);
> > +    return av_dict_set(&s->metadata, key, buf, AV_DICT_DONT_STRDUP_VAL);
> >  }
> >
> >  static const AVMetadataConv vqf_metadata_conv[] = {
> > @@ -165,7 +170,9 @@ static int vqf_read_header(AVFormatContext *s)
> >              avio_skip(s->pb, FFMIN(len, header_size));
> >              break;
> >          default:
> > -            add_metadata(s, chunk_tag, len, header_size);
> > +            ret = add_metadata(s, chunk_tag, len, header_size);
> > +            if (ret < 0)
> > +                return ret;
> >              break;
> >          }
> >
> > --
> 
> LGTM regarding my review comments.

will apply

thx

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

There will always be a question for which you do not know the correct answer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250121/b5664174/attachment.sig>


More information about the ffmpeg-devel mailing list