[FFmpeg-devel] [PATCH 5/5] avcodec/osq: Fix 32bit sample overflow

Michael Niedermayer michael at niedermayer.cc
Mon Jul 14 21:58:52 EEST 2025


On Sun, Jul 13, 2025 at 07:37:06PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: signed integer overflow: 2147483565 + 128 cannot be represented in type 'int'
> > Fixes: 428055715/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6358069900804096
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> >  libavcodec/osq.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/osq.c b/libavcodec/osq.c
> > index 76090aa8d07..1d99ab32451 100644
> > --- a/libavcodec/osq.c
> > +++ b/libavcodec/osq.c
> > @@ -390,7 +390,7 @@ static int osq_decode_block(AVCodecContext *avctx, AVFrame *frame)
> >              int32_t *src = s->decode_buffer[ch] + OFFSET;
> >  
> >              for (int n = 0; n < nb_samples; n++)
> > -                dst[n] = av_clip_uint8(src[n] + 0x80);
> > +                dst[n] = av_clip_uint8(src[n] + 0x80ll);
> >          }
> >          break;
> >      case AV_SAMPLE_FMT_S16P:
> 
> Why do you use a 64bit intermediate instead of simply using unsigned
> like we do everywhere else?

we can use an unsigned but the intend was to clip obviously
and while the C code uses 64bit the optimized asm should not
need that

Iam happy to change it to unsigned if you prefer

[...]

thx

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- 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/20250714/445b39ef/attachment.sig>


More information about the ffmpeg-devel mailing list