diff mbox series

[FFmpeg-devel,5/5] avcodec/atrac9dec: Check init_get_bits8() for failure

Message ID 20240428213052.3800493-5-michael@niedermayer.cc
State Accepted
Commit 615c994739cacbeb0a2f48f8271d911fcd0b4303
Headers show
Series [FFmpeg-devel,1/5] tools/opt_common: Check for malloc failure | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Michael Niedermayer April 28, 2024, 9:30 p.m. UTC
Fixes: CID1439569 Unchecked return value
Fixes: CID1439578 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/atrac9dec.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Lynne April 28, 2024, 9:41 p.m. UTC | #1
Apr 28, 2024, 23:31 by michael@niedermayer.cc:

> Fixes: CID1439569 Unchecked return value
> Fixes: CID1439578 Unchecked return value
>
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/atrac9dec.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
> index df68407af92..e375f46fd04 100644
> --- a/libavcodec/atrac9dec.c
> +++ b/libavcodec/atrac9dec.c
> @@ -802,7 +802,9 @@ static int atrac9_decode_frame(AVCodecContext *avctx, AVFrame *frame,
>  if (ret < 0)
>  return ret;
>  
> -    init_get_bits8(&gb, avpkt->data, avpkt->size);
> +    ret = init_get_bits8(&gb, avpkt->data, avpkt->size);
> +    if (ret < 0)
> +        return ret;
>  
>  for (int i = 0; i < frames; i++) {
>  for (int j = 0; j < s->block_config->count; j++) {
> @@ -922,7 +924,9 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx)
>  return AVERROR_INVALIDDATA;
>  }
>  
> -    init_get_bits8(&gb, avctx->extradata + 4, avctx->extradata_size);
> +    err = init_get_bits8(&gb, avctx->extradata + 4, avctx->extradata_size);
> +    if (err < 0)
> +        return err;
>  
>  if (get_bits(&gb, 8) != 0xFE) {
>  av_log(avctx, AV_LOG_ERROR, "Incorrect magic byte!\n");
>

This and ac3 lgtm
Paul B Mahol April 29, 2024, 6:52 a.m. UTC | #2
On Sun, Apr 28, 2024 at 11:31 PM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> Fixes: CID1439569 Unchecked return value
> Fixes: CID1439578 Unchecked return value
>
> Sponsored-by: Sovereign Tech Fund
>

And they paid you for this low effort work!

Applause!



> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/atrac9dec.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
> index df68407af92..e375f46fd04 100644
> --- a/libavcodec/atrac9dec.c
> +++ b/libavcodec/atrac9dec.c
> @@ -802,7 +802,9 @@ static int atrac9_decode_frame(AVCodecContext *avctx,
> AVFrame *frame,
>      if (ret < 0)
>          return ret;
>
> -    init_get_bits8(&gb, avpkt->data, avpkt->size);
> +    ret = init_get_bits8(&gb, avpkt->data, avpkt->size);
> +    if (ret < 0)
> +        return ret;
>
>      for (int i = 0; i < frames; i++) {
>          for (int j = 0; j < s->block_config->count; j++) {
> @@ -922,7 +924,9 @@ static av_cold int atrac9_decode_init(AVCodecContext
> *avctx)
>          return AVERROR_INVALIDDATA;
>      }
>
> -    init_get_bits8(&gb, avctx->extradata + 4, avctx->extradata_size);
> +    err = init_get_bits8(&gb, avctx->extradata + 4,
> avctx->extradata_size);
> +    if (err < 0)
> +        return err;
>
>      if (get_bits(&gb, 8) != 0xFE) {
>          av_log(avctx, AV_LOG_ERROR, "Incorrect magic byte!\n");
> --
> 2.43.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Michael Niedermayer April 29, 2024, 11:30 p.m. UTC | #3
On Mon, Apr 29, 2024 at 08:52:32AM +0200, Paul B Mahol wrote:
> On Sun, Apr 28, 2024 at 11:31 PM Michael Niedermayer <michael@niedermayer.cc>
> wrote:
> 
> > Fixes: CID1439569 Unchecked return value
> > Fixes: CID1439578 Unchecked return value
> >
> > Sponsored-by: Sovereign Tech Fund
> >
> 
> And they paid you for this low effort work!

not yet, i have over 600 coverity issues to go over, ATM coverity lists 677
outstanding.

some are in fact low effort, I wish all where low effort sadly thats not the case

Also these issues are open since many years (these 2 here since 2018)
apparently they where too high effort for anyone to deal with them before

also you and everyone is very welcome to submit a proposal / SoW
for any maintaince work. Low effort, High effort, anything ffmpeg
related. I presume there will be future rounds from STF


> 
> Applause!

thx

[...]
Michael Niedermayer April 30, 2024, 10:53 p.m. UTC | #4
On Sun, Apr 28, 2024 at 11:41:48PM +0200, Lynne wrote:
> Apr 28, 2024, 23:31 by michael@niedermayer.cc:
> 
> > Fixes: CID1439569 Unchecked return value
> > Fixes: CID1439578 Unchecked return value
> >
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/atrac9dec.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
> > index df68407af92..e375f46fd04 100644
> > --- a/libavcodec/atrac9dec.c
> > +++ b/libavcodec/atrac9dec.c
> > @@ -802,7 +802,9 @@ static int atrac9_decode_frame(AVCodecContext *avctx, AVFrame *frame,
> >  if (ret < 0)
> >  return ret;
> >  
> > -    init_get_bits8(&gb, avpkt->data, avpkt->size);
> > +    ret = init_get_bits8(&gb, avpkt->data, avpkt->size);
> > +    if (ret < 0)
> > +        return ret;
> >  
> >  for (int i = 0; i < frames; i++) {
> >  for (int j = 0; j < s->block_config->count; j++) {
> > @@ -922,7 +924,9 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx)
> >  return AVERROR_INVALIDDATA;
> >  }
> >  
> > -    init_get_bits8(&gb, avctx->extradata + 4, avctx->extradata_size);
> > +    err = init_get_bits8(&gb, avctx->extradata + 4, avctx->extradata_size);
> > +    if (err < 0)
> > +        return err;
> >  
> >  if (get_bits(&gb, 8) != 0xFE) {
> >  av_log(avctx, AV_LOG_ERROR, "Incorrect magic byte!\n");
> >
> 
> This and ac3 lgtm

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index df68407af92..e375f46fd04 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -802,7 +802,9 @@  static int atrac9_decode_frame(AVCodecContext *avctx, AVFrame *frame,
     if (ret < 0)
         return ret;
 
-    init_get_bits8(&gb, avpkt->data, avpkt->size);
+    ret = init_get_bits8(&gb, avpkt->data, avpkt->size);
+    if (ret < 0)
+        return ret;
 
     for (int i = 0; i < frames; i++) {
         for (int j = 0; j < s->block_config->count; j++) {
@@ -922,7 +924,9 @@  static av_cold int atrac9_decode_init(AVCodecContext *avctx)
         return AVERROR_INVALIDDATA;
     }
 
-    init_get_bits8(&gb, avctx->extradata + 4, avctx->extradata_size);
+    err = init_get_bits8(&gb, avctx->extradata + 4, avctx->extradata_size);
+    if (err < 0)
+        return err;
 
     if (get_bits(&gb, 8) != 0xFE) {
         av_log(avctx, AV_LOG_ERROR, "Incorrect magic byte!\n");