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

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Jul 13 20:37:06 EEST 2025


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?

- Andreas



More information about the ffmpeg-devel mailing list