135.26. audiofile-0.3.6
SGI's audio file library: reads and writes AIFF, WAVE, NeXT/Sun, IRCAM, AVR, CAF and FLAC through one API
| Version | 0.3.6, release 1 |
| Shelf | audio-codecs — Audio codecs, containers and tagging, including the Bluetooth audio codecs |
| Phase | 41_system (System), 132 of 1047 in build order |
| Licence | LGPL-2.1-or-later AND GPL-2.0-or-later |
| Homepage | https://audiofile.68k.org/ |
| Build time | 0.4 SBU |
| Installed size | 421.9 KiB in 44 files |
| Recipe | ports/core/audio-codecs/audiofile/kpkgbuild |
About
The Audio File Library reads and writes AIFF, AIFF-C, WAVE, NeXT/Sun, IRCAM, AVR, CAF and FLAC files through one C API, libaudiofile, and installs the sfconvert and sfinfo commands. The patches beside it are Debian’s series for this release: overflow, division-by-zero and out-of-bounds checks in the decoders and in sfconvert and sfinfo, and one change that lets it compile with GCC 6 and later. In KDOS, libspectrum and kwave link it.
Sources
audiofile-0.3.6.tar.gz(792.7 KiB)
sha256cdc60df19ab08bfe55344395739bb08f50fc15c92da3962fac334d3bff116965
upstream: https://audiofile.68k.org/audiofile-0.3.6.tar.gz
archive copy: sources-1/audio-codecs--audiofile-0.3.6.tar.gz
Dependencies
Depends on: autoconf, automake, libtool, pkgconf, flac.
Required by (2): kwave, libspectrum.
Patches
build.sh applies these; kpkg applies nothing by itself.
0013-Fix-CVE-2022-24599.patch— Fix CVE-2022-24599Memory-leak bug in printfileinfo, due to memcpy on an non allocated memory buffer with a user declared string.
Fix it by calloc(declaredsize+1,1) that zeros the buffer and terminate by '\0' for printf
Avoid also a buffer overflow by refusing to allocating more than INT_MAX-1.
Before under valgrind: libtool --mode=execute valgrind --track-origins=yes ./sfinfo heapleak_poc.aiff
Duration -inf seconds ==896222== Invalid read of size 1 ==896222== at 0x4846794: strlen (vg_replace_strmem.c:494) ==896222== by 0x49246C8: __printf_buffer (vfprintf-process-arg.c:435) ==896222== by 0x4924D90: __vfprintf_internal (vfprintf-internal.c:1459) ==896222== by 0x49DE986: __printf_chk (printf_chk.c:33) ==896222== by 0x10985C: printf (stdio2.h:86) ==896222== by 0x10985C: printfileinfo (printinfo.c:134) ==896222== by 0x10930A: main (sfinfo.c:113) ==896222== Address 0x4e89bd1 is 0 bytes after a block of size 1 alloc'd ==896222== at 0x48407B4: malloc (vg_replace_malloc.c:381) ==896222== by 0x109825: copyrightstring (printinfo.c:163) ==896222== by 0x109825: printfileinfo (printinfo.c:131) ==896222== by 0x10930A: main (sfinfo.c:113) ==896222== Copyright C
After: Duration -inf seconds Copyright C
forwarded: https://github.com/mpruett/audiofile/issues/60 bug: https://github.com/mpruett/audiofile/issues/60 bug-debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1008017 bug-debian-security: https://security-tracker.debian.org/tracker/CVE-2022-24599
0014-Partial-fix-of-CVE-2019-13147.patch— Partial fix of CVE-2019-13147This fix the symptom do not allow to allocate negative memory: ==129695==WARNING: AddressSanitizer failed to allocate 0xffffffffc2c00000 bytes ==129695==AddressSanitizer's allocator is terminating the process instead of returning 0 ==129695==If you don't like this behavior set allocator_may_return_null=1 ==129695==AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_allocator.cc:218 "((0)) != (0)" (0x0, 0x0) #0 0x7f48c8503c02 (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe9c02) #1 0x7f48c8522595 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x108595) #2 0x7f48c8509342 (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xef342) #3 0x7f48c8441e46 (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x27e46) #4 0x7f48c84f8b1a in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb1a) #5 0x558dc209af68 in copyaudiodata /home/tim/audiofile-santi/sfcommands/sfconvert.c:327 #6 0x558dc209a620 in main /home/tim/audiofile-santi/sfcommands/sfconvert.c:248 #7 0x7f48c7d38b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) #8 0x558dc209ac79 in _start (/home/tim/audiofile-santi/sfcommands/.libs/sfconvert+0x1c79)
If negative bail out
bug: https://github.com/mpruett/audiofile/issues/54 forwarded: https://github.com/mpruett/audiofile/issues/54 bug-debian-security: https://security-tracker.debian.org/tracker/CVE-2019-13147 bug-debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=931343
0015-Partial-fix-of-CVE-2019-13147.patch— Partial fix of CVE-2019-13147This is the fix of the POC. Do not allow too many channel
Now it fail with: Audio File Library: invalid file with 1633771873 channels [error 15] Could not open file 'poc' for reading.
bug: https://github.com/mpruett/audiofile/issues/54 forwarded: https://github.com/mpruett/audiofile/issues/54 bug-debian-security: https://security-tracker.debian.org/tracker/CVE-2019-13147 bug-debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=931343
01_gcc6.patch— Writes the shifted minimum values inSimpleModule.hand three tests as0-(1U<<n)instead of-1 << n, which is undefined for a signed left shift, and declares the NeXT test data assigned char, so the source compiles with GCC 6 and later.03_CVE-2015-7747.patch— Passes the output format, not the input format, to the channel-matrix module when a conversion changes both the sample format and the channel count, which overflowed a buffer (CVE-2015-7747), and adds thesixteen-stereo-to-eight-monotest for it.04_clamp-index-values-to-fix-index-overflow-in-IMA.cpp.patch— clamp index values to fix index overflow in IMA.cppThis fixes #33 (also reported at https://bugzilla.opensuse.org/show_bug.cgi?id=1026981 and https://blogs.gentoo.org/ago/2017/02/20/audiofile-global-buffer-overflow-in-decodesample-ima-cpp/)
05_Always-check-the-number-of-coefficients.patch— Always check the number of coefficientsWhen building the library with NDEBUG, asserts are eliminated so it's better to always check that the number of coefficients is inside the array range.
This fixes the 00191-audiofile-indexoob issue in #41
06_Check-for-multiplication-overflow-in-MSADPCM-decodeSam.patch— Check for multiplication overflow in MSADPCM decodeSampleCheck for multiplication overflow (using __builtin_mul_overflow if available) in MSADPCM.cpp decodeSample and return an empty decoded block if an error occurs.
This fixes the 00193-audiofile-signintoverflow-MSADPCM case of #41
07_Check-for-multiplication-overflow-in-sfconvert.patch— Check for multiplication overflow in sfconvertChecks that a multiplication doesn't overflow when calculating the buffer size, and if it overflows, reduce the buffer size instead of failing.
This fixes the 00192-audiofile-signintoverflow-sfconvert case in #41
08_Fix-signature-of-multiplyCheckOverflow.-It-returns-a-b.patch— Fix signature of multiplyCheckOverflow. It returns a bool, not an int09_Actually-fail-when-error-occurs-in-parseFormat.patch— Actually fail when error occurs in parseFormatWhen there's an unsupported number of bits per sample or an invalid number of samples per block, don't only print an error message using the error handler, but actually stop parsing the file.
This fixes #35 (also reported at https://bugzilla.opensuse.org/show_bug.cgi?id=1026983 and https://blogs.gentoo.org/ago/2017/02/20/audiofile-heap-based-buffer-overflow-in-imadecodeblockwave-ima-cpp/ )
10_Check-for-division-by-zero-in-BlockCodec-runPull.patch— Check for division by zero in BlockCodec::runPull11_CVE-2018-13440.patch— ModuleState: handle compress/decompress init failureWhen the unit initcompress or initdecompress function fails, m_fileModule is NULL. Return AF_FAIL in that case instead of causing NULL pointer dereferences later.
Fixes #49
12_CVE-2018-17095.patch— SimpleModule: set output chunk framecount after pullAfter pulling the data, set the output chunk to the amount of frames we pulled so that the next module in the chain has the correct frame count.
Fixes #50 and #51
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install audiofile'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/audio-codecs/audiofile.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/audio-codecs/audiofile
echo 'cdc60df19ab08bfe55344395739bb08f50fc15c92da3962fac334d3bff116965 audiofile-0.3.6.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/audiofile
SRC=$SRC_ROOT/audiofile-0.3.6
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf audiofile-0.3.6.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
for p in \
01_gcc6 \
03_CVE-2015-7747 \
04_clamp-index-values-to-fix-index-overflow-in-IMA.cpp \
05_Always-check-the-number-of-coefficients \
06_Check-for-multiplication-overflow-in-MSADPCM-decodeSam \
07_Check-for-multiplication-overflow-in-sfconvert \
08_Fix-signature-of-multiplyCheckOverflow.-It-returns-a-b \
09_Actually-fail-when-error-occurs-in-parseFormat \
10_Check-for-division-by-zero-in-BlockCodec-runPull \
11_CVE-2018-13440 \
12_CVE-2018-17095 \
0013-Fix-CVE-2022-24599 \
0014-Partial-fix-of-CVE-2019-13147 \
0015-Partial-fix-of-CVE-2019-13147; do
patch -p1 -i "$PORT_SRC/$p.patch"
done
autoreconf -fi
./configure --prefix=/usr --libdir=/usr/lib --disable-static \
--enable-flac \
--disable-examples \
--disable-werror \
--disable-coverage \
--disable-valgrind
make
make DESTDIR=$PKG install
The switches, and why each is set:
--enable-flac— Build the FLAC reader and writer againstlibFLAC, which is whyflacis a dependency. It is upstream’s default, and it does not make a missinglibFLACfatal: whenpkg-configcannot findflac >= 1.2.1, configure turns FLAC off without an error.--disable-examples— Leave out the platform playback examples. On Linux these arelinuxtest, which opens the OSS device through<linux/soundcard.h>, andalsaplay, which links ALSA, and neither is installed;alsa-libis not a dependency of this port.--disable-werror— Do not add-Werrorto the compile. This is upstream’s default as well, so the switch only states the choice.--disable-coverage,--disable-valgrind— Thegcovinstrumentation and the Valgrind run of the test suite, both off by default upstream and both off here.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/audiofile, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf audiofile-0.3.6-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/audiofile, and runs the triggers its paths call for.
Contents
Installed programs: sfconvert, sfinfo.
Installed libraries: libaudiofile.so.
Installed directories: /usr/share/licenses/audiofile.
Short descriptions
sfconvert |
convert audio files |
sfinfo |
display information about audio files |
audiofile.pc |
audiofile |
Notes
- None of the patches is optional. The library parses whatever file an editor or a converter is handed, and most of them are bounds and overflow checks in its decoders.
- The patches are a list, applied in Debian’s order.
build.shnames each one in aforloop; a glob would sort0013before01, and a patch file dropped into the directory without a line in that loop is never applied. autoreconf -firuns beforeconfigure.03_CVE-2015-7747.patchadds a test totest/Makefile.am, which makes the release’s generatedMakefile.instale; without regenerating up front,makewould call the automake version the tarball was made with.- The manual pages ship prebuilt in the tarball and are installed as they are, so the documentation tools are not dependencies.