blob: b1c94057a3bf308aa830aca19a31bc78dda34003 [file] [log] [blame]
Patrick Williams213cb262021-08-07 19:21:33 -05001From a7a7f32c8ad0179a1a85d0a8cff35924e6d90be8 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michael@niedermayer.cc>
3Date: Fri, 28 May 2021 21:37:26 +0200
4Subject: [PATCH] avcodec/aacenc: Avoid 0 lambda
5
6Fixes: Ticket8003
7Fixes: CVE-2020-20453
8
9Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
10
11CVE: CVE-2020-20453
12Upstream-Status: Backport [a7a7f32c8ad0179a1a85d0a8cff35924e6d90be8]
13
14Signed-off-by: Tony Tascioglu <tony.tascioglu@windriver.com>
15---
16 libavcodec/aacenc.c | 3 ++-
17 1 file changed, 2 insertions(+), 1 deletion(-)
18
19diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
20index 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--
412.32.0
42