1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
7 SDESC[standard]= Library to handle various audio file formats
8 HOMEPAGE= https://audiofile.68k.org/
12 SITES[main]= GNOME/audiofile/0.3
13 DISTFILE[1]= audiofile-0.3.6.tar.xz:main
15 SPKGS[standard]= single
17 OPTIONS_AVAILABLE= none
18 OPTIONS_STANDARD= none
20 BUILDRUN_DEPENDS= flac:primary:standard
22 USES= cpe pkgconfig libtool c++:single
24 LICENSE= LGPL21+:single
25 LICENSE_TERMS= single:{{WRKDIR}}/TERMS
26 LICENSE_FILE= LGPL21+:{{WRKSRC}}/COPYING
29 FPC_EQUIVALENT= audio/libaudiofile
33 INSTALL_TARGET= install-strip
37 # extract license terms
38 ${AWK} '/Audio File Library itself/,EOF' ${WRKSRC}/README\
41 [FILE:987:descriptions/desc.single]
42 The Audio File Library is a C-based library for reading and writing audio
43 files in many common formats.
45 The Audio File Library provides a uniform API which abstracts away details
46 of file formats and data formats. The same calls for opening a file,
47 accessing and manipulating audio metadata (e.g. sample rate, sample format,
48 textual information, MIDI parameters), and reading and writing sample data
49 will work with any supported audio file format. The Audio File Library lets
50 you work with audio data in whatever format is most convenient for you.
52 Supported file formats:
53 - AIFF/AIFF-C (.aiff, .aifc)
55 - NeXT .snd/Sun .au (.snd, .au)
56 - Berkeley/IRCAM/CARL Sound File (.sf)
57 - Audio Visual Research (.avr)
58 - Amiga IFF/8SVX (.iff)
59 - Sample Vision (.smp)
60 - Creative Voice File (.voc)
62 - Core Audio Format (.caf)
65 Supported compression formats:
66 - G.711 mu-law and A-law
70 - ALAC (Apple Lossless Audio Codec)
74 ea2449ad3f201ec590d811db9da6d02ffc5e87a677d06b92ab15363d8cb59782 530760 audiofile-0.3.6.tar.xz
77 [FILE:924:manifests/plist.single]
88 libaudiofile.so.%%SOMAJOR%%
89 libaudiofile.so.%%SOVERSION%%
90 lib/pkgconfig/audiofile.pc
100 afInitAESChannelData.3.gz
101 afInitAESChannelDataTo.3.gz
104 afInitCompression.3.gz
105 afInitFileFormat.3.gz
107 afInitSampleFormat.3.gz
118 afSetErrorHandler.3.gz
119 afSetVirtualByteOrder.3.gz
120 afSetVirtualChannels.3.gz
121 afSetVirtualPCMMapping.3.gz
122 afSetVirtualSampleFormat.3.gz
128 [FILE:2907:patches/patch-01_gcc6]
129 Description: Fix FTBFS with GCC 6
130 Author: Michael Schwendt <mschwendt@fedoraproject.org>
131 Origin: vendor, https://github.com/mpruett/audiofile/pull/27
132 Bug-Debian: https://bugs.debian.org/812055
134 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
136 --- libaudiofile/modules/SimpleModule.h
137 +++ libaudiofile/modules/SimpleModule.h
138 @@ -123,7 +123,7 @@ struct signConverter
139 typedef typename IntTypes<Format>::UnsignedType UnsignedType;
141 static const int kScaleBits = (Format + 1) * CHAR_BIT - 1;
142 - static const int kMinSignedValue = -1 << kScaleBits;
143 + static const int kMinSignedValue = 0-(1U<<kScaleBits);
145 struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
147 --- test/FloatToInt.cpp
148 +++ test/FloatToInt.cpp
149 @@ -115,7 +115,7 @@ TEST_F(FloatToIntTest, Int16)
150 EXPECT_EQ(readData[i], expectedData[i]);
153 -static const int32_t kMinInt24 = -1<<23;
154 +static const int32_t kMinInt24 = 0-(1U<<23);
155 static const int32_t kMaxInt24 = (1<<23) - 1;
157 TEST_F(FloatToIntTest, Int24)
158 --- test/IntToFloat.cpp
159 +++ test/IntToFloat.cpp
160 @@ -117,7 +117,7 @@ TEST_F(IntToFloatTest, Int16)
161 EXPECT_EQ(readData[i], expectedData[i]);
164 -static const int32_t kMinInt24 = -1<<23;
165 +static const int32_t kMinInt24 = 0-(1U<<23);
166 static const int32_t kMaxInt24 = (1<<23) - 1;
168 TEST_F(IntToFloatTest, Int24)
173 #include "TestUtilities.h"
175 -const char kDataUnspecifiedLength[] =
176 +const signed char kDataUnspecifiedLength[] =
179 0, 0, 0, 24, // offset of 24 bytes
180 - 0xff, 0xff, 0xff, 0xff, // unspecified length
181 + -1, -1, -1, -1, // unspecified length
182 0, 0, 0, 3, // 16-bit linear
183 - 0, 0, 172, 68, // 44100 Hz
184 + 0, 0, -84, 68, // 44100 Hz (0xAC44)
185 0, 0, 0, 1, // 1 channel
188 @@ -57,13 +57,13 @@ const char kDataUnspecifiedLength[] =
192 -const char kDataTruncated[] =
193 +const signed char kDataTruncated[] =
196 0, 0, 0, 24, // offset of 24 bytes
197 0, 0, 0, 20, // length of 20 bytes
198 0, 0, 0, 3, // 16-bit linear
199 - 0, 0, 172, 68, // 44100 Hz
200 + 0, 0, -84, 68, // 44100 Hz (0xAC44)
201 0, 0, 0, 1, // 1 channel
204 @@ -152,13 +152,13 @@ TEST(NeXT, Truncated)
205 ASSERT_EQ(::unlink(testFileName.c_str()), 0);
208 -const char kDataZeroChannels[] =
209 +const signed char kDataZeroChannels[] =
212 0, 0, 0, 24, // offset of 24 bytes
213 0, 0, 0, 2, // 2 bytes
214 0, 0, 0, 3, // 16-bit linear
215 - 0, 0, 172, 68, // 44100 Hz
216 + 0, 0, -84, 68, // 44100 Hz (0xAC44)
217 0, 0, 0, 0, // 0 channels
222 @@ -116,7 +116,7 @@ TEST_F(SignConversionTest, Int16)
223 EXPECT_EQ(readData[i], expectedData[i]);
226 -static const int32_t kMinInt24 = -1<<23;
227 +static const int32_t kMinInt24 = 0-(1U<<23);
228 static const int32_t kMaxInt24 = (1<<23) - 1;
229 static const uint32_t kMaxUInt24 = (1<<24) - 1;
233 [FILE:10170:patches/patch-02_hurd]
234 Description: Remove usage of PATH_MAX in tests to fix FTBFS on Hurd.
235 jcowgill: Removed Changelog changes
236 Author: Pino Toscano <toscano.pino@tiscali.it>
237 Origin: backport, https://github.com/mpruett/audiofile/commit/34c261034f1193a783196618f0052112e00fbcfe
238 Bug: https://github.com/mpruett/audiofile/pull/17
239 Bug-Debian: https://bugs.debian.org/762595
241 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
243 --- test/TestUtilities.cpp
244 +++ test/TestUtilities.cpp
246 #include "TestUtilities.h"
254 bool createTemporaryFile(const std::string &prefix, std::string *path)
255 @@ -35,12 +35,12 @@ bool createTemporaryFile(const std::stri
259 -bool createTemporaryFile(const char *prefix, char *path)
260 +bool createTemporaryFile(const char *prefix, char **path)
262 - snprintf(path, PATH_MAX, "/tmp/%s-XXXXXX", prefix);
263 - int fd = ::mkstemp(path);
269 + std::string pathString;
270 + bool result = createTemporaryFile(prefix, &pathString);
272 + *path = ::strdup(pathString.c_str());
275 --- test/TestUtilities.h
276 +++ test/TestUtilities.h
277 @@ -53,7 +53,7 @@ extern "C" {
281 -bool createTemporaryFile(const char *prefix, char *path);
282 +bool createTemporaryFile(const char *prefix, char **path);
288 @@ -86,8 +86,8 @@ int main (int argc, char **argv)
289 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
290 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_FLOAT, 32);
292 - char testFileName[PATH_MAX];
293 - if (!createTemporaryFile("floatto24", testFileName))
294 + char *testFileName;
295 + if (!createTemporaryFile("floatto24", &testFileName))
297 fprintf(stderr, "Could not create temporary file.\n");
299 @@ -182,6 +182,7 @@ int main (int argc, char **argv)
302 unlink(testFileName);
303 + free(testFileName);
307 --- test/sixteen-to-eight.c
308 +++ test/sixteen-to-eight.c
309 @@ -57,8 +57,8 @@ int main (int argc, char **argv)
310 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_UNSIGNED, 8);
311 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
313 - char testFileName[PATH_MAX];
314 - if (!createTemporaryFile("sixteen-to-eight", testFileName))
315 + char *testFileName;
316 + if (!createTemporaryFile("sixteen-to-eight", &testFileName))
318 fprintf(stderr, "Could not create temporary file.\n");
320 @@ -113,6 +113,7 @@ int main (int argc, char **argv)
323 unlink(testFileName);
324 + free(testFileName);
328 --- test/testchannelmatrix.c
329 +++ test/testchannelmatrix.c
332 #include "TestUtilities.h"
334 -static char sTestFileName[PATH_MAX];
335 +static char *sTestFileName;
337 const short samples[] = {300, -300, 515, -515, 2315, -2315, 9154, -9154};
338 #define SAMPLE_COUNT (sizeof (samples) / sizeof (short))
339 @@ -47,7 +47,11 @@ const short samples[] = {300, -300, 515,
343 - unlink(sTestFileName);
346 + unlink(sTestFileName);
347 + free(sTestFileName);
351 void ensure (int condition, const char *message)
352 @@ -76,7 +80,7 @@ int main (void)
353 afInitFileFormat(setup, AF_FILE_AIFFC);
355 /* Write stereo data to test file. */
356 - ensure(createTemporaryFile("testchannelmatrix", sTestFileName),
357 + ensure(createTemporaryFile("testchannelmatrix", &sTestFileName),
358 "could not create temporary file");
359 file = afOpenFile(sTestFileName, "w", setup);
360 ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
361 --- test/testdouble.c
362 +++ test/testdouble.c
365 #include "TestUtilities.h"
367 -static char sTestFileName[PATH_MAX];
368 +static char *sTestFileName;
370 const double samples[] =
371 {1.0, 0.6, -0.3, 0.95, 0.2, -0.6, 0.9, 0.4, -0.22, 0.125, 0.1, -0.4};
372 @@ -48,7 +48,11 @@ void testdouble (int fileFormat);
376 - unlink(sTestFileName);
379 + unlink(sTestFileName);
380 + free(sTestFileName);
384 void ensure (int condition, const char *message)
385 @@ -96,7 +100,7 @@ void testdouble (int fileFormat)
386 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_DOUBLE, 64);
387 afInitChannels(setup, AF_DEFAULT_TRACK, 2);
389 - ensure(createTemporaryFile("testdouble", sTestFileName),
390 + ensure(createTemporaryFile("testdouble", &sTestFileName),
391 "could not create temporary file");
392 file = afOpenFile(sTestFileName, "w", setup);
393 ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
398 #include "TestUtilities.h"
400 -static char sTestFileName[PATH_MAX];
401 +static char *sTestFileName;
403 const float samples[] =
404 {1.0, 0.6, -0.3, 0.95, 0.2, -0.6, 0.9, 0.4, -0.22, 0.125, 0.1, -0.4};
405 @@ -48,7 +48,11 @@ void testfloat (int fileFormat);
409 - unlink(sTestFileName);
412 + unlink(sTestFileName);
413 + free(sTestFileName);
417 void ensure (int condition, const char *message)
418 @@ -96,7 +100,7 @@ void testfloat (int fileFormat)
419 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_FLOAT, 32);
420 afInitChannels(setup, AF_DEFAULT_TRACK, 2);
422 - ensure(createTemporaryFile("testfloat", sTestFileName),
423 + ensure(createTemporaryFile("testfloat", &sTestFileName),
424 "could not create temporary file");
425 file = afOpenFile(sTestFileName, "w", setup);
426 ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
427 --- test/testmarkers.c
428 +++ test/testmarkers.c
431 #include "TestUtilities.h"
433 -static char sTestFileName[PATH_MAX];
434 +static char *sTestFileName;
436 #define FRAME_COUNT 200
443 - unlink(sTestFileName);
444 + unlink(sTestFileName);
446 + free(sTestFileName);
450 void ensure (int condition, const char *message)
451 @@ -127,7 +131,7 @@ int testmarkers (int fileformat)
455 - ensure(createTemporaryFile("testmarkers", sTestFileName),
456 + ensure(createTemporaryFile("testmarkers", &sTestFileName),
457 "could not create temporary file");
459 testmarkers(AF_FILE_AIFF);
460 --- test/twentyfour.c
461 +++ test/twentyfour.c
462 @@ -71,8 +71,8 @@ int main (int argc, char **argv)
463 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24);
464 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
466 - char testFileName[PATH_MAX];
467 - if (!createTemporaryFile("twentyfour", testFileName))
468 + char *testFileName;
469 + if (!createTemporaryFile("twentyfour", &testFileName))
471 fprintf(stderr, "could not create temporary file\n");
473 @@ -239,6 +239,7 @@ int main (int argc, char **argv)
476 unlink(testFileName);
477 + free(testFileName);
481 --- test/twentyfour2.c
482 +++ test/twentyfour2.c
485 #include "TestUtilities.h"
487 -static char sTestFileName[PATH_MAX];
488 +static char *sTestFileName;
490 #define FRAME_COUNT 10000
497 - unlink(sTestFileName);
498 + unlink(sTestFileName);
500 + free(sTestFileName);
504 void ensure (int condition, const char *message)
505 @@ -78,7 +82,7 @@ int main (void)
506 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
507 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24);
509 - ensure(createTemporaryFile("twentyfour2", sTestFileName),
510 + ensure(createTemporaryFile("twentyfour2", &sTestFileName),
511 "could not create temporary file");
512 file = afOpenFile(sTestFileName, "w", setup);
513 ensure(file != NULL, "could not open test file for writing");
518 #include "TestUtilities.h"
520 -static char sTestFileName[PATH_MAX];
521 +static char *sTestFileName;
523 #define FRAME_COUNT 16
524 #define SAMPLE_COUNT FRAME_COUNT
525 @@ -62,9 +62,13 @@ void testalaw (int fileFormat);
532 - unlink(sTestFileName);
533 + unlink(sTestFileName);
535 + free(sTestFileName);
539 void ensure (int condition, const char *message)
540 @@ -113,7 +117,7 @@ void testalaw (int fileFormat)
541 afInitFileFormat(setup, fileFormat);
542 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
544 - ensure(createTemporaryFile("writealaw", sTestFileName),
545 + ensure(createTemporaryFile("writealaw", &sTestFileName),
546 "could not create temporary file");
547 file = afOpenFile(sTestFileName, "w", setup);
548 afFreeFileSetup(setup);
553 #include "TestUtilities.h"
555 -static char sTestFileName[PATH_MAX];
556 +static char *sTestFileName;
563 - unlink(sTestFileName);
564 + unlink(sTestFileName);
566 + free(sTestFileName);
570 void ensure (int condition, const char *message)
571 @@ -84,7 +88,7 @@ int main (int argc, char **argv)
572 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
573 afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
575 - ensure(createTemporaryFile("writeraw", sTestFileName),
576 + ensure(createTemporaryFile("writeraw", &sTestFileName),
577 "could not create temporary file");
578 file = afOpenFile(sTestFileName, "w", setup);
579 ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing");
584 #include "TestUtilities.h"
586 -static char sTestFileName[PATH_MAX];
587 +static char *sTestFileName;
589 #define FRAME_COUNT 16
590 #define SAMPLE_COUNT FRAME_COUNT
591 @@ -62,9 +62,13 @@ void testulaw (int fileFormat);
598 - unlink(sTestFileName);
599 + unlink(sTestFileName);
601 + free(sTestFileName);
605 void ensure (int condition, const char *message)
606 @@ -113,7 +117,7 @@ void testulaw (int fileFormat)
607 afInitFileFormat(setup, fileFormat);
608 afInitChannels(setup, AF_DEFAULT_TRACK, 1);
610 - ensure(createTemporaryFile("writeulaw", sTestFileName),
611 + ensure(createTemporaryFile("writeulaw", &sTestFileName),
612 "could not create temporary file");
613 file = afOpenFile(sTestFileName, "w", setup);
614 afFreeFileSetup(setup);
617 [FILE:4290:patches/patch-03_CVE-2015-7747]
618 Description: fix buffer overflow when changing both sample format and
620 Origin: https://github.com/mpruett/audiofile/pull/25
621 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/audiofile/+bug/1502721
622 Bug-Debian: https://bugs.debian.org/801102
624 --- libaudiofile/modules/ModuleState.cpp
625 +++ libaudiofile/modules/ModuleState.cpp
626 @@ -402,7 +402,7 @@ status ModuleState::arrange(AFfilehandle
627 addModule(new Transform(outfc, in.pcm, out.pcm));
629 if (in.channelCount != out.channelCount)
630 - addModule(new ApplyChannelMatrix(infc, isReading,
631 + addModule(new ApplyChannelMatrix(outfc, isReading,
632 in.channelCount, out.channelCount,
633 in.pcm.minClip, in.pcm.maxClip,
634 track->channelMatrix));
637 @@ -26,6 +26,7 @@ TESTS = \
641 + sixteen-stereo-to-eight-mono \
645 @@ -139,6 +140,7 @@ printmarkers_SOURCES = printmarkers.c
646 printmarkers_LDADD = $(LIBAUDIOFILE) -lm
648 sixteen_to_eight_SOURCES = sixteen-to-eight.c TestUtilities.cpp TestUtilities.h
649 +sixteen_stereo_to_eight_mono_SOURCES = sixteen-stereo-to-eight-mono.c TestUtilities.cpp TestUtilities.h
651 testchannelmatrix_SOURCES = testchannelmatrix.c TestUtilities.cpp TestUtilities.h
654 +++ test/sixteen-stereo-to-eight-mono.c
659 + Copyright 2000, Silicon Graphics, Inc.
661 + This program is free software; you can redistribute it and/or modify
662 + it under the terms of the GNU General Public License as published by
663 + the Free Software Foundation; either version 2 of the License, or
664 + (at your option) any later version.
666 + This program is distributed in the hope that it will be useful,
667 + but WITHOUT ANY WARRANTY; without even the implied warranty of
668 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
669 + GNU General Public License for more details.
671 + You should have received a copy of the GNU General Public License along
672 + with this program; if not, write to the Free Software Foundation, Inc.,
673 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
677 + sixteen-stereo-to-eight-mono.c
679 + This program tests the conversion from 2-channel 16-bit integers to
680 + 1-channel 8-bit integers.
683 +#ifdef HAVE_CONFIG_H
694 +#include <audiofile.h>
696 +#include "TestUtilities.h"
698 +int main (int argc, char **argv)
702 + int16_t frames16[] = {14298, 392, 3923, -683, 958, -1921};
703 + int8_t frames8[] = {28, 6, -2};
704 + int i, frameCount = 3;
706 + AFframecount result;
708 + setup = afNewFileSetup();
710 + afInitFileFormat(setup, AF_FILE_WAVE);
712 + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
713 + afInitChannels(setup, AF_DEFAULT_TRACK, 2);
715 + char *testFileName;
716 + if (!createTemporaryFile("sixteen-to-eight", &testFileName))
718 + fprintf(stderr, "Could not create temporary file.\n");
719 + exit(EXIT_FAILURE);
722 + file = afOpenFile(testFileName, "w", setup);
723 + if (file == AF_NULL_FILEHANDLE)
725 + fprintf(stderr, "could not open file for writing\n");
726 + exit(EXIT_FAILURE);
729 + afFreeFileSetup(setup);
731 + afWriteFrames(file, AF_DEFAULT_TRACK, frames16, frameCount);
735 + file = afOpenFile(testFileName, "r", AF_NULL_FILESETUP);
736 + if (file == AF_NULL_FILEHANDLE)
738 + fprintf(stderr, "could not open file for reading\n");
739 + exit(EXIT_FAILURE);
742 + afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 8);
743 + afSetVirtualChannels(file, AF_DEFAULT_TRACK, 1);
745 + for (i=0; i<frameCount; i++)
747 + /* Read one frame. */
748 + result = afReadFrames(file, AF_DEFAULT_TRACK, &byte, 1);
753 + /* Compare the byte read with its precalculated value. */
754 + if (memcmp(&byte, &frames8[i], 1) != 0)
757 + printf("expected %d, got %d\n", frames8[i], byte);
758 + exit(EXIT_FAILURE);
763 + printf("got what was expected: %d\n", byte);
769 + unlink(testFileName);
770 + free(testFileName);
772 + exit(EXIT_SUCCESS);
776 [FILE:1119:patches/patch-04_clamp-index-values-to-fix-index-overflow-in-IMA.cpp]
777 From: Antonio Larrosa <larrosa@kde.org>
778 Date: Mon, 6 Mar 2017 18:02:31 +0100
779 Subject: clamp index values to fix index overflow in IMA.cpp
782 (also reported at https://bugzilla.opensuse.org/show_bug.cgi?id=1026981
783 and https://blogs.gentoo.org/ago/2017/02/20/audiofile-global-buffer-overflow-in-decodesample-ima-cpp/)
785 libaudiofile/modules/IMA.cpp | 4 ++--
786 1 file changed, 2 insertions(+), 2 deletions(-)
788 --- libaudiofile/modules/IMA.cpp
789 +++ libaudiofile/modules/IMA.cpp
790 @@ -169,7 +169,7 @@ int IMA::decodeBlockWAVE(const uint8_t *encoded, int16_t *decoded)
791 if (encoded[1] & 0x80)
792 m_adpcmState[c].previousValue -= 0x10000;
794 - m_adpcmState[c].index = encoded[2];
795 + m_adpcmState[c].index = clamp(encoded[2], 0, 88);
797 *decoded++ = m_adpcmState[c].previousValue;
799 @@ -210,7 +210,7 @@ int IMA::decodeBlockQT(const uint8_t *encoded, int16_t *decoded)
800 predictor -= 0x10000;
802 state.previousValue = clamp(predictor, MIN_INT16, MAX_INT16);
803 - state.index = encoded[1] & 0x7f;
804 + state.index = clamp(encoded[1] & 0x7f, 0, 88);
807 for (int n=0; n<m_framesPerPacket; n+=2)
810 [FILE:854:patches/patch-05_Always-check-the-number-of-coefficients]
811 From: Antonio Larrosa <larrosa@kde.org>
812 Date: Mon, 6 Mar 2017 12:51:22 +0100
813 Subject: Always check the number of coefficients
815 When building the library with NDEBUG, asserts are eliminated
816 so it's better to always check that the number of coefficients
817 is inside the array range.
819 This fixes the 00191-audiofile-indexoob issue in #41
821 libaudiofile/WAVE.cpp | 6 ++++++
822 1 file changed, 6 insertions(+)
824 --- libaudiofile/WAVE.cpp
825 +++ libaudiofile/WAVE.cpp
826 @@ -281,6 +281,12 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
828 /* numCoefficients should be at least 7. */
829 assert(numCoefficients >= 7 && numCoefficients <= 255);
830 + if (numCoefficients < 7 || numCoefficients > 255)
832 + _af_error(AF_BAD_HEADER,
833 + "Bad number of coefficients");
837 m_msadpcmNumCoefficients = numCoefficients;
841 [FILE:3471:patches/patch-06_Check-for-multiplication-overflow-in-MSADPCM-decodeSam]
842 From: Antonio Larrosa <larrosa@kde.org>
843 Date: Mon, 6 Mar 2017 13:43:53 +0100
844 Subject: Check for multiplication overflow in MSADPCM decodeSample
846 Check for multiplication overflow (using __builtin_mul_overflow
847 if available) in MSADPCM.cpp decodeSample and return an empty
848 decoded block if an error occurs.
850 This fixes the 00193-audiofile-signintoverflow-MSADPCM case of #41
852 libaudiofile/modules/BlockCodec.cpp | 5 ++--
853 libaudiofile/modules/MSADPCM.cpp | 47 +++++++++++++++++++++++++++++++++----
854 2 files changed, 46 insertions(+), 6 deletions(-)
856 --- libaudiofile/modules/BlockCodec.cpp
857 +++ libaudiofile/modules/BlockCodec.cpp
858 @@ -52,8 +52,9 @@ void BlockCodec::runPull()
859 // Decompress into m_outChunk.
860 for (int i=0; i<blocksRead; i++)
862 - decodeBlock(static_cast<const uint8_t *>(m_inChunk->buffer) + i * m_bytesPerPacket,
863 - static_cast<int16_t *>(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount);
864 + if (decodeBlock(static_cast<const uint8_t *>(m_inChunk->buffer) + i * m_bytesPerPacket,
865 + static_cast<int16_t *>(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount)==0)
868 framesRead += m_framesPerPacket;
870 --- libaudiofile/modules/MSADPCM.cpp
871 +++ libaudiofile/modules/MSADPCM.cpp
872 @@ -101,24 +101,60 @@ static const int16_t adaptationTable[] =
873 768, 614, 512, 409, 307, 230, 230, 230
876 +int firstBitSet(int x)
887 +#ifndef __has_builtin
888 +#define __has_builtin(x) 0
891 +int multiplyCheckOverflow(int a, int b, int *result)
893 +#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
894 + return __builtin_mul_overflow(a, b, result);
896 + if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits
904 // Compute a linear PCM value from the given differential coded value.
905 static int16_t decodeSample(ms_adpcm_state &state,
906 - uint8_t code, const int16_t *coefficient)
907 + uint8_t code, const int16_t *coefficient, bool *ok=NULL)
909 int linearSample = (state.sample1 * coefficient[0] +
910 state.sample2 * coefficient[1]) >> 8;
913 linearSample += ((code & 0x08) ? (code - 0x10) : code) * state.delta;
915 linearSample = clamp(linearSample, MIN_INT16, MAX_INT16);
917 - int delta = (state.delta * adaptationTable[code]) >> 8;
918 + if (multiplyCheckOverflow(state.delta, adaptationTable[code], &delta))
921 + _af_error(AF_BAD_COMPRESSION, "Error decoding sample");
929 state.sample2 = state.sample1;
930 state.sample1 = linearSample;
933 return static_cast<int16_t>(linearSample);
935 @@ -212,13 +248,16 @@ int MSADPCM::decodeBlock(const uint8_t *encoded, int16_t *decoded)
941 code = *encoded >> 4;
942 - newSample = decodeSample(*state[0], code, coefficient[0]);
943 + newSample = decodeSample(*state[0], code, coefficient[0], &ok);
945 *decoded++ = newSample;
947 code = *encoded & 0x0f;
948 - newSample = decodeSample(*state[1], code, coefficient[1]);
949 + newSample = decodeSample(*state[1], code, coefficient[1], &ok);
951 *decoded++ = newSample;
956 [FILE:1880:patches/patch-07_Check-for-multiplication-overflow-in-sfconvert]
957 From: Antonio Larrosa <larrosa@kde.org>
958 Date: Mon, 6 Mar 2017 13:54:52 +0100
959 Subject: Check for multiplication overflow in sfconvert
961 Checks that a multiplication doesn't overflow when
962 calculating the buffer size, and if it overflows,
963 reduce the buffer size instead of failing.
965 This fixes the 00192-audiofile-signintoverflow-sfconvert case
968 sfcommands/sfconvert.c | 34 ++++++++++++++++++++++++++++++++--
969 1 file changed, 32 insertions(+), 2 deletions(-)
971 --- sfcommands/sfconvert.c
972 +++ sfcommands/sfconvert.c
973 @@ -45,6 +45,33 @@ void printusage (void);
974 void usageerror (void);
975 bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid);
977 +int firstBitSet(int x)
988 +#ifndef __has_builtin
989 +#define __has_builtin(x) 0
992 +int multiplyCheckOverflow(int a, int b, int *result)
994 +#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
995 + return __builtin_mul_overflow(a, b, result);
997 + if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits
1004 int main (int argc, char **argv)
1007 @@ -323,8 +350,11 @@ bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid)
1009 int frameSize = afGetVirtualFrameSize(infile, trackid, 1);
1011 - const int kBufferFrameCount = 65536;
1012 - void *buffer = malloc(kBufferFrameCount * frameSize);
1013 + int kBufferFrameCount = 65536;
1015 + while (multiplyCheckOverflow(kBufferFrameCount, frameSize, &bufferSize))
1016 + kBufferFrameCount /= 2;
1017 + void *buffer = malloc(bufferSize);
1019 AFframecount totalFrames = afGetFrameCount(infile, AF_DEFAULT_TRACK);
1020 AFframecount totalFramesWritten = 0;
1023 [FILE:1097:patches/patch-08_Fix-signature-of-multiplyCheckOverflow.-It-returns-a-b]
1024 From: Antonio Larrosa <larrosa@kde.org>
1025 Date: Fri, 10 Mar 2017 15:40:02 +0100
1026 Subject: Fix signature of multiplyCheckOverflow. It returns a bool, not an int
1029 libaudiofile/modules/MSADPCM.cpp | 2 +-
1030 sfcommands/sfconvert.c | 2 +-
1031 2 files changed, 2 insertions(+), 2 deletions(-)
1033 --- libaudiofile/modules/MSADPCM.cpp
1034 +++ libaudiofile/modules/MSADPCM.cpp
1035 @@ -116,7 +116,7 @@ int firstBitSet(int x)
1036 #define __has_builtin(x) 0
1039 -int multiplyCheckOverflow(int a, int b, int *result)
1040 +bool multiplyCheckOverflow(int a, int b, int *result)
1042 #if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
1043 return __builtin_mul_overflow(a, b, result);
1044 --- sfcommands/sfconvert.c
1045 +++ sfcommands/sfconvert.c
1046 @@ -60,7 +60,7 @@ int firstBitSet(int x)
1047 #define __has_builtin(x) 0
1050 -int multiplyCheckOverflow(int a, int b, int *result)
1051 +bool multiplyCheckOverflow(int a, int b, int *result)
1053 #if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
1054 return __builtin_mul_overflow(a, b, result);
1057 [FILE:1179:patches/patch-09_Actually-fail-when-error-occurs-in-parseFormat]
1058 From: Antonio Larrosa <larrosa@kde.org>
1059 Date: Mon, 6 Mar 2017 18:59:26 +0100
1060 Subject: Actually fail when error occurs in parseFormat
1062 When there's an unsupported number of bits per sample or an invalid
1063 number of samples per block, don't only print an error message using
1064 the error handler, but actually stop parsing the file.
1066 This fixes #35 (also reported at
1067 https://bugzilla.opensuse.org/show_bug.cgi?id=1026983 and
1068 https://blogs.gentoo.org/ago/2017/02/20/audiofile-heap-based-buffer-overflow-in-imadecodeblockwave-ima-cpp/
1071 libaudiofile/WAVE.cpp | 2 ++
1072 1 file changed, 2 insertions(+)
1074 --- libaudiofile/WAVE.cpp
1075 +++ libaudiofile/WAVE.cpp
1076 @@ -332,6 +332,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
1078 _af_error(AF_BAD_NOT_IMPLEMENTED,
1079 "IMA ADPCM compression supports only 4 bits per sample");
1083 int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
1084 @@ -339,6 +340,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
1086 _af_error(AF_BAD_CODEC_CONFIG,
1087 "Invalid samples per block for IMA ADPCM compression");
1091 track->f.sampleWidth = 16;
1094 [FILE:705:patches/patch-10_Check-for-division-by-zero-in-BlockCodec-runPull]
1095 From: Antonio Larrosa <larrosa@kde.org>
1096 Date: Thu, 9 Mar 2017 10:21:18 +0100
1097 Subject: Check for division by zero in BlockCodec::runPull
1100 libaudiofile/modules/BlockCodec.cpp | 2 +-
1101 1 file changed, 1 insertion(+), 1 deletion(-)
1103 --- libaudiofile/modules/BlockCodec.cpp
1104 +++ libaudiofile/modules/BlockCodec.cpp
1105 @@ -47,7 +47,7 @@ void BlockCodec::runPull()
1107 // Read the compressed data.
1108 ssize_t bytesRead = read(m_inChunk->buffer, m_bytesPerPacket * blockCount);
1109 - int blocksRead = bytesRead >= 0 ? bytesRead / m_bytesPerPacket : 0;
1110 + int blocksRead = (bytesRead >= 0 && m_bytesPerPacket > 0) ? bytesRead / m_bytesPerPacket : 0;
1112 // Decompress into m_outChunk.
1113 for (int i=0; i<blocksRead; i++)
1116 [FILE:911:patches/patch-11_CVE-2018-13440]
1117 From fde6d79fb8363c4a329a184ef0b107156602b225 Mon Sep 17 00:00:00 2001
1118 From: Wim Taymans <wtaymans@redhat.com>
1119 Date: Thu, 27 Sep 2018 10:48:45 +0200
1120 Subject: [PATCH] ModuleState: handle compress/decompress init failure
1122 When the unit initcompress or initdecompress function fails,
1123 m_fileModule is NULL. Return AF_FAIL in that case instead of
1124 causing NULL pointer dereferences later.
1128 libaudiofile/modules/ModuleState.cpp | 3 +++
1129 1 file changed, 3 insertions(+)
1131 --- libaudiofile/modules/ModuleState.cpp
1132 +++ libaudiofile/modules/ModuleState.cpp
1133 @@ -75,6 +75,9 @@ status ModuleState::initFileModule(AFfilehandle file, Track *track)
1134 m_fileModule = unit->initcompress(track, file->m_fh, file->m_seekok,
1135 file->m_fileFormat == AF_FILE_RAWDATA, &chunkFrames);
1137 + if (!m_fileModule)
1140 if (unit->needsRebuffer)
1142 assert(unit->nativeSampleFormat == AF_SAMPFMT_TWOSCOMP);
1145 [FILE:720:patches/patch-12_CVE-2018-17095]
1146 From 822b732fd31ffcb78f6920001e9b1fbd815fa712 Mon Sep 17 00:00:00 2001
1147 From: Wim Taymans <wtaymans@redhat.com>
1148 Date: Thu, 27 Sep 2018 12:11:12 +0200
1149 Subject: [PATCH] SimpleModule: set output chunk framecount after pull
1151 After pulling the data, set the output chunk to the amount of
1152 frames we pulled so that the next module in the chain has the correct
1157 libaudiofile/modules/SimpleModule.cpp | 1 +
1158 1 file changed, 1 insertion(+)
1160 --- libaudiofile/modules/SimpleModule.cpp
1161 +++ libaudiofile/modules/SimpleModule.cpp
1163 void SimpleModule::runPull()
1165 pull(m_outChunk->frameCount);
1166 + m_outChunk->frameCount = m_inChunk->frameCount;
1167 run(*m_inChunk, *m_outChunk);
1172 [FILE:435:patches/patch-configure]
1173 --- configure.orig 2013-03-07 07:27:14 UTC
1175 @@ -15956,10 +15956,6 @@ platform=none
1176 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for platform specific tests to compile" >&5
1177 $as_echo_n "checking for platform specific tests to compile... " >&6; }
1180 - TEST_BIN="linuxtest alsaplay"
1184 TEST_BIN="irixread irixtestloop"