[FFmpeg-cvslog] avcodec/apedec: Use NABS to avoid undefined negation

Michael Niedermayer git at videolan.org
Sun Apr 14 04:45:04 EEST 2024


ffmpeg | branch: release/6.1 | Michael Niedermayer <michael at niedermayer.cc> | Mon Apr  1 22:11:54 2024 +0200| [72b27f4f70fc81e9ee28dab325d2d203dfa231e5] | committer: Michael Niedermayer

avcodec/apedec: Use NABS to avoid undefined negation

Fixes: negation of -2147483648 cannot be represented in type 'int32_t' (aka 'int'); cast to an unsigned type to negate this value to itself
Fixes: 67738/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5444313212321792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 1887ff250cfd1e69c08bca21cc53e30a39e26818)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=72b27f4f70fc81e9ee28dab325d2d203dfa231e5
---

 libavcodec/apedec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index d31c067152..4f4fd54833 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1286,7 +1286,7 @@ static void predictor_decode_stereo_3950(APEContext *ctx, int count)
                 int32_t left  = a1 - (unsigned)(a0 / 2);
                 int32_t right = left + (unsigned)a0;
 
-                if (FFMAX(FFABS(left), FFABS(right)) > (1<<23)) {
+                if (FFMIN(FFNABS(left), FFNABS(right)) < -(1<<23)) {
                     ctx->interim_mode = !interim_mode;
                     av_log(ctx->avctx, AV_LOG_VERBOSE, "Interim mode: %d\n", ctx->interim_mode);
                     break;



More information about the ffmpeg-cvslog mailing list