Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 1 | From a7a7f32c8ad0179a1a85d0a8cff35924e6d90be8 Mon Sep 17 00:00:00 2001 |
| 2 | From: Michael Niedermayer <michael@niedermayer.cc> |
| 3 | Date: Fri, 28 May 2021 21:37:26 +0200 |
| 4 | Subject: [PATCH] avcodec/aacenc: Avoid 0 lambda |
| 5 | |
| 6 | Fixes: Ticket8003 |
| 7 | Fixes: CVE-2020-20453 |
| 8 | |
| 9 | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> |
| 10 | |
| 11 | CVE: CVE-2020-20453 |
| 12 | Upstream-Status: Backport [a7a7f32c8ad0179a1a85d0a8cff35924e6d90be8] |
| 13 | |
| 14 | Signed-off-by: Tony Tascioglu <tony.tascioglu@windriver.com> |
| 15 | --- |
| 16 | libavcodec/aacenc.c | 3 ++- |
| 17 | 1 file changed, 2 insertions(+), 1 deletion(-) |
| 18 | |
| 19 | diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c |
| 20 | index aa223cf25f..e80591ba86 100644 |
| 21 | --- a/libavcodec/aacenc.c |
| 22 | +++ b/libavcodec/aacenc.c |
| 23 | @@ -28,6 +28,7 @@ |
| 24 | * TODOs: |
| 25 | * add sane pulse detection |
| 26 | ***********************************/ |
| 27 | +#include <float.h> |
| 28 | |
| 29 | #include "libavutil/libm.h" |
| 30 | #include "libavutil/float_dsp.h" |
| 31 | @@ -852,7 +853,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, |
| 32 | /* Not so fast though */ |
| 33 | ratio = sqrtf(ratio); |
| 34 | } |
| 35 | - s->lambda = FFMIN(s->lambda * ratio, 65536.f); |
| 36 | + s->lambda = av_clipf(s->lambda * ratio, FLT_MIN, 65536.f); |
| 37 | |
| 38 | /* Keep iterating if we must reduce and lambda is in the sky */ |
| 39 | if (ratio > 0.9f && ratio < 1.1f) { |
| 40 | -- |
| 41 | 2.32.0 |
| 42 | |