at 23.05-pre 95 lines 3.5 kB view raw
1{ stdenv, lib, fetchurl, fetchpatch, alsa-lib, AudioUnit, CoreServices }: 2 3let 4 5 fetchDebianPatch = { name, debname, sha256 }: 6 fetchpatch { 7 inherit sha256 name; 8 url = "https://salsa.debian.org/multimedia-team/audiofile/raw/debian/0.3.6-4/debian/patches/${debname}"; 9 }; 10 11in 12 13stdenv.mkDerivation rec { 14 pname = "audiofile"; 15 version = "0.3.6"; 16 17 buildInputs = 18 lib.optionals stdenv.isLinux [ 19 alsa-lib 20 ] ++ lib.optionals stdenv.isDarwin [ 21 CoreServices AudioUnit 22 ]; 23 24 src = fetchurl { 25 url = "https://audiofile.68k.org/audiofile-${version}.tar.gz"; 26 sha256 = "0rb927zknk9kmhprd8rdr4azql4gn2dp75a36iazx2xhkbqhvind"; 27 }; 28 29 # fix build with gcc9 30 NIX_CFLAGS_LINK = lib.optional (stdenv.system == "i686-linux") "-lgcc"; 31 32 # Even when statically linking, libstdc++.la is put in dependency_libs here, 33 # and hence libstdc++.so passed to the linker, just pass -lstdc++ and let the 34 # compiler do what it does best. (libaudiofile.la is a generated file, so we 35 # have to run `make` that far first). 36 # 37 # Without this, the executables in this package (sfcommands and examples) 38 # fail to build: https://github.com/NixOS/nixpkgs/issues/103215 39 # 40 # There might be a more sensible way to do this with autotools, but I am not 41 # smart enough to discover it. 42 preBuild = lib.optionalString stdenv.hostPlatform.isStatic '' 43 make -C libaudiofile $makeFlags 44 sed -i "s/dependency_libs=.*/dependency_libs=' -lstdc++'/" libaudiofile/libaudiofile.la 45 ''; 46 47 patches = [ 48 ./gcc-6.patch 49 ./CVE-2015-7747.patch 50 51 (fetchDebianPatch { 52 name = "CVE-2017-6829.patch"; 53 debname = "04_clamp-index-values-to-fix-index-overflow-in-IMA.cpp.patch"; 54 sha256 = "04qxl51i64c53v69q2kx61qdq474f4vapk8rq97cipj7yrar392m"; 55 }) 56 (fetchDebianPatch { 57 name = "CVE-2017-6827+CVE-2017-6828+CVE-2017-6832+CVE-2017-6835+CVE-2017-6837.patch"; 58 debname = "05_Always-check-the-number-of-coefficients.patch"; 59 sha256 = "1ih03kfkabffi6ymp6832q470i28rsds78941vzqlshnqjb2nnxw"; 60 }) 61 (fetchDebianPatch { 62 name = "CVE-2017-6839.patch"; 63 debname = "06_Check-for-multiplication-overflow-in-MSADPCM-decodeSam.patch"; 64 sha256 = "0a8s2z8rljlj03p7l1is9s4fml8vyzvyvfrh1m6xj5a8vbi635d0"; 65 }) 66 (fetchDebianPatch { 67 name = "CVE-2017-6830+CVE-2017-6834+CVE-2017-6836+CVE-2017-6838.patch"; 68 debname = "07_Check-for-multiplication-overflow-in-sfconvert.patch"; 69 sha256 = "0rfba8rkasl5ycvc0kqlzinkl3rvyrrjvjhpc45h423wmjk2za2l"; 70 }) 71 (fetchDebianPatch { 72 name = "audiofile-fix-multiplyCheckOverflow-signature.patch"; 73 debname = "08_Fix-signature-of-multiplyCheckOverflow.-It-returns-a-b.patch"; 74 sha256 = "032p5jqp7q7jgc5axdnazz00zm7hd26z6m5j55ifs0sykr5lwldb"; 75 }) 76 (fetchDebianPatch { 77 name = "CVE-2017-6831.patch"; 78 debname = "09_Actually-fail-when-error-occurs-in-parseFormat.patch"; 79 sha256 = "0csikmj8cbiy6cigg0rmh67jrr0sgm56dfrnrxnac3m9635nxlac"; 80 }) 81 (fetchDebianPatch { 82 name = "CVE-2017-6833.patch"; 83 debname = "10_Check-for-division-by-zero-in-BlockCodec-runPull.patch"; 84 sha256 = "1rlislkjawq98bbcf1dgl741zd508wwsg85r37ca7pfdf6wgl6z7"; 85 }) 86 ]; 87 88 meta = with lib; { 89 description = "Library for reading and writing audio files in various formats"; 90 homepage = "http://www.68k.org/~michael/audiofile/"; 91 license = licenses.lgpl21Plus; 92 maintainers = with maintainers; [ lovek323 ]; 93 platforms = platforms.unix; 94 }; 95}