summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Marko <peter.marko@siemens.com>2024-12-27 11:56:13 +0100
committerKhem Raj <raj.khem@gmail.com>2024-12-27 09:21:44 -0800
commit75f2bd2b3b145d8282db9926d8212c6d81bde99e (patch)
tree2588c7b23e6e806d52730bfc5acbb753095eeff1
parentf29fbaa4650201a059c65572947ed8faa991fcd8 (diff)
downloadmeta-openembedded-75f2bd2b3b145d8282db9926d8212c6d81bde99e.tar.gz
audiofile: fix multiple CVEs
CVE-2017-6830 / CVE-2017-6834 / CVE-2017-6836 / CVE-2017-6838 Use patch from buildroot: https://github.com/buildroot/buildroot/commit/4a1a8277bba490d227f413e218138e39f1fe1203 Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb1
-rw-r--r--meta-oe/recipes-multimedia/audiofile/files/0006-Check-for-multiplication-overflow-in-sfconvert.patch79
2 files changed, 80 insertions, 0 deletions
diff --git a/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb b/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb
index 67c1992cc4..66194fdc8b 100644
--- a/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb
+++ b/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb
@@ -15,6 +15,7 @@ SRC_URI = " \
15 file://0003-fix-CVE-2015-7747.patch \ 15 file://0003-fix-CVE-2015-7747.patch \
16 file://0004-Always-check-the-number-of-coefficients.patch \ 16 file://0004-Always-check-the-number-of-coefficients.patch \
17 file://0005-clamp-index-values-to-fix-index-overflow-in-IMA.cpp.patch \ 17 file://0005-clamp-index-values-to-fix-index-overflow-in-IMA.cpp.patch \
18 file://0006-Check-for-multiplication-overflow-in-sfconvert.patch \
18" 19"
19SRC_URI[sha256sum] = "ea2449ad3f201ec590d811db9da6d02ffc5e87a677d06b92ab15363d8cb59782" 20SRC_URI[sha256sum] = "ea2449ad3f201ec590d811db9da6d02ffc5e87a677d06b92ab15363d8cb59782"
20 21
diff --git a/meta-oe/recipes-multimedia/audiofile/files/0006-Check-for-multiplication-overflow-in-sfconvert.patch b/meta-oe/recipes-multimedia/audiofile/files/0006-Check-for-multiplication-overflow-in-sfconvert.patch
new file mode 100644
index 0000000000..ec21b09f30
--- /dev/null
+++ b/meta-oe/recipes-multimedia/audiofile/files/0006-Check-for-multiplication-overflow-in-sfconvert.patch
@@ -0,0 +1,79 @@
1From 7d65f89defb092b63bcbc5d98349fb222ca73b3c Mon Sep 17 00:00:00 2001
2From: Antonio Larrosa <larrosa@kde.org>
3Date: Mon, 6 Mar 2017 13:54:52 +0100
4Subject: [PATCH] Check for multiplication overflow in sfconvert
5
6Checks that a multiplication doesn't overflow when
7calculating the buffer size, and if it overflows,
8reduce the buffer size instead of failing.
9
10This fixes the 00192-audiofile-signintoverflow-sfconvert case
11in #41
12
13Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
14
15CVE: CVE-2017-6830
16CVE: CVE-2017-6834
17CVE: CVE-2017-6836
18CVE: CVE-2017-6838
19Upstream-Status: Inactive-Upstream [lastrelease: 2013]
20Signed-off-by: Peter Marko <peter.marko@siemens.com>
21---
22 sfcommands/sfconvert.c | 34 ++++++++++++++++++++++++++++++++--
23 1 file changed, 32 insertions(+), 2 deletions(-)
24
25diff --git a/sfcommands/sfconvert.c b/sfcommands/sfconvert.c
26index 80a1bc4..970a3e4 100644
27--- a/sfcommands/sfconvert.c
28+++ b/sfcommands/sfconvert.c
29@@ -45,6 +45,33 @@ void printusage (void);
30 void usageerror (void);
31 bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid);
32
33+int firstBitSet(int x)
34+{
35+ int position=0;
36+ while (x!=0)
37+ {
38+ x>>=1;
39+ ++position;
40+ }
41+ return position;
42+}
43+
44+#ifndef __has_builtin
45+#define __has_builtin(x) 0
46+#endif
47+
48+int multiplyCheckOverflow(int a, int b, int *result)
49+{
50+#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
51+ return __builtin_mul_overflow(a, b, result);
52+#else
53+ if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits
54+ return true;
55+ *result = a * b;
56+ return false;
57+#endif
58+}
59+
60 int main (int argc, char **argv)
61 {
62 if (argc == 2)
63@@ -323,8 +350,11 @@ bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid)
64 {
65 int frameSize = afGetVirtualFrameSize(infile, trackid, 1);
66
67- const int kBufferFrameCount = 65536;
68- void *buffer = malloc(kBufferFrameCount * frameSize);
69+ int kBufferFrameCount = 65536;
70+ int bufferSize;
71+ while (multiplyCheckOverflow(kBufferFrameCount, frameSize, &bufferSize))
72+ kBufferFrameCount /= 2;
73+ void *buffer = malloc(bufferSize);
74
75 AFframecount totalFrames = afGetFrameCount(infile, AF_DEFAULT_TRACK);
76 AFframecount totalFramesWritten = 0;
77--
782.11.0
79