git » audiofile.git » commit 093544f

upgpkg: 0.3.6-5

author David Runge
2019-09-02 22:01:03 UTC
committer David Runge
2019-09-02 22:01:03 UTC
parent 67c2f39bcbde0a277a948f996e8f4b59c5b20757

upgpkg: 0.3.6-5

Adding patch for running tests (02_hurd.patch) and patches for CVE-2018-13440 (11_CVE-2018-13440.patch) and CVE-2018-17095 (12_CVE-2018-17095.patch), provided by Debian and unmerged fixes by Wim Taymans (respectively).
Simplifying the application of the (many) patches in prepare(). Running autoreconf in prepare().
Running make check in check() and installing docs. Switching to correct license (GPL2 and LGPL2.1) and updating maintainer. Adding libaudiofile.so to provides.

02_hurd.patch +381 -0
11_CVE-2018-13440.patch +28 -0
12_CVE-2018-17095.patch +26 -0
PKGBUILD +40 -29

diff --git a/02_hurd.patch b/02_hurd.patch
new file mode 100644
index 0000000..b5941dc
--- /dev/null
+++ b/02_hurd.patch
@@ -0,0 +1,381 @@
+Description: Remove usage of PATH_MAX in tests to fix FTBFS on Hurd.
+ jcowgill: Removed Changelog changes
+Author: Pino Toscano <toscano.pino@tiscali.it>
+Origin: backport, https://github.com/mpruett/audiofile/commit/34c261034f1193a783196618f0052112e00fbcfe
+Bug: https://github.com/mpruett/audiofile/pull/17
+Bug-Debian: https://bugs.debian.org/762595
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+
+--- a/test/TestUtilities.cpp
++++ b/test/TestUtilities.cpp
+@@ -21,8 +21,8 @@
+ #include "TestUtilities.h"
+ 
+ #include <limits.h>
+-#include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+ #include <unistd.h>
+ 
+ bool createTemporaryFile(const std::string &prefix, std::string *path)
+@@ -35,12 +35,12 @@ bool createTemporaryFile(const std::stri
+ 	return true;
+ }
+ 
+-bool createTemporaryFile(const char *prefix, char *path)
++bool createTemporaryFile(const char *prefix, char **path)
+ {
+-	snprintf(path, PATH_MAX, "/tmp/%s-XXXXXX", prefix);
+-	int fd = ::mkstemp(path);
+-	if (fd < 0)
+-		return false;
+-	::close(fd);
+-	return true;
++	*path = NULL;
++	std::string pathString;
++	bool result = createTemporaryFile(prefix, &pathString);
++	if (result)
++		*path = ::strdup(pathString.c_str());
++	return result;
+ }
+--- a/test/TestUtilities.h
++++ b/test/TestUtilities.h
+@@ -53,7 +53,7 @@ extern "C" {
+ 
+ #include <stdbool.h>
+ 
+-bool createTemporaryFile(const char *prefix, char *path);
++bool createTemporaryFile(const char *prefix, char **path);
+ 
+ #ifdef __cplusplus
+ }
+--- a/test/floatto24.c
++++ b/test/floatto24.c
+@@ -86,8 +86,8 @@ int main (int argc, char **argv)
+ 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);
+ 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_FLOAT, 32);
+ 
+-	char testFileName[PATH_MAX];
+-	if (!createTemporaryFile("floatto24", testFileName))
++	char *testFileName;
++	if (!createTemporaryFile("floatto24", &testFileName))
+ 	{
+ 		fprintf(stderr, "Could not create temporary file.\n");
+ 		exit(EXIT_FAILURE);
+@@ -182,6 +182,7 @@ int main (int argc, char **argv)
+ 	}
+ 
+ 	unlink(testFileName);
++	free(testFileName);
+ 
+ 	exit(EXIT_SUCCESS);
+ }
+--- a/test/sixteen-to-eight.c
++++ b/test/sixteen-to-eight.c
+@@ -57,8 +57,8 @@ int main (int argc, char **argv)
+ 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_UNSIGNED, 8);
+ 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);
+ 
+-	char testFileName[PATH_MAX];
+-	if (!createTemporaryFile("sixteen-to-eight", testFileName))
++	char *testFileName;
++	if (!createTemporaryFile("sixteen-to-eight", &testFileName))
+ 	{
+ 		fprintf(stderr, "Could not create temporary file.\n");
+ 		exit(EXIT_FAILURE);
+@@ -113,6 +113,7 @@ int main (int argc, char **argv)
+ 
+ 	afCloseFile(file);
+ 	unlink(testFileName);
++	free(testFileName);
+ 
+ 	exit(EXIT_SUCCESS);
+ }
+--- a/test/testchannelmatrix.c
++++ b/test/testchannelmatrix.c
+@@ -39,7 +39,7 @@
+ 
+ #include "TestUtilities.h"
+ 
+-static char sTestFileName[PATH_MAX];
++static char *sTestFileName;
+ 
+ const short samples[] = {300, -300, 515, -515, 2315, -2315, 9154, -9154};
+ #define SAMPLE_COUNT (sizeof (samples) / sizeof (short))
+@@ -47,7 +47,11 @@ const short samples[] = {300, -300, 515,
+ 
+ void cleanup (void)
+ {
+-	unlink(sTestFileName);
++	if (sTestFileName)
++	{
++		unlink(sTestFileName);
++		free(sTestFileName);
++	}
+ }
+ 
+ void ensure (int condition, const char *message)
+@@ -76,7 +80,7 @@ int main (void)
+ 	afInitFileFormat(setup, AF_FILE_AIFFC);
+ 
+ 	/* Write stereo data to test file. */
+-	ensure(createTemporaryFile("testchannelmatrix", sTestFileName),
++	ensure(createTemporaryFile("testchannelmatrix", &sTestFileName),
+ 		"could not create temporary file");
+ 	file = afOpenFile(sTestFileName, "w", setup);
+ 	ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
+--- a/test/testdouble.c
++++ b/test/testdouble.c
+@@ -38,7 +38,7 @@
+ 
+ #include "TestUtilities.h"
+ 
+-static char sTestFileName[PATH_MAX];
++static char *sTestFileName;
+ 
+ const double samples[] =
+ 	{1.0, 0.6, -0.3, 0.95, 0.2, -0.6, 0.9, 0.4, -0.22, 0.125, 0.1, -0.4};
+@@ -48,7 +48,11 @@ void testdouble (int fileFormat);
+ 
+ void cleanup (void)
+ {
+-	unlink(sTestFileName);
++	if (sTestFileName)
++	{
++		unlink(sTestFileName);
++		free(sTestFileName);
++	}
+ }
+ 
+ void ensure (int condition, const char *message)
+@@ -96,7 +100,7 @@ void testdouble (int fileFormat)
+ 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_DOUBLE, 64);
+ 	afInitChannels(setup, AF_DEFAULT_TRACK, 2);
+ 
+-	ensure(createTemporaryFile("testdouble", sTestFileName),
++	ensure(createTemporaryFile("testdouble", &sTestFileName),
+ 		"could not create temporary file");
+ 	file = afOpenFile(sTestFileName, "w", setup);
+ 	ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
+--- a/test/testfloat.c
++++ b/test/testfloat.c
+@@ -38,7 +38,7 @@
+ 
+ #include "TestUtilities.h"
+ 
+-static char sTestFileName[PATH_MAX];
++static char *sTestFileName;
+ 
+ const float samples[] =
+ 	{1.0, 0.6, -0.3, 0.95, 0.2, -0.6, 0.9, 0.4, -0.22, 0.125, 0.1, -0.4};
+@@ -48,7 +48,11 @@ void testfloat (int fileFormat);
+ 
+ void cleanup (void)
+ {
+-	unlink(sTestFileName);
++	if (sTestFileName)
++	{
++		unlink(sTestFileName);
++		free(sTestFileName);
++	}
+ }
+ 
+ void ensure (int condition, const char *message)
+@@ -96,7 +100,7 @@ void testfloat (int fileFormat)
+ 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_FLOAT, 32);
+ 	afInitChannels(setup, AF_DEFAULT_TRACK, 2);
+ 
+-	ensure(createTemporaryFile("testfloat", sTestFileName),
++	ensure(createTemporaryFile("testfloat", &sTestFileName),
+ 		"could not create temporary file");
+ 	file = afOpenFile(sTestFileName, "w", setup);
+ 	ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
+--- a/test/testmarkers.c
++++ b/test/testmarkers.c
+@@ -32,15 +32,19 @@
+ 
+ #include "TestUtilities.h"
+ 
+-static char sTestFileName[PATH_MAX];
++static char *sTestFileName;
+ 
+ #define FRAME_COUNT 200
+ 
+ void cleanup (void)
+ {
++	if (sTestFileName)
++	{
+ #ifndef DEBUG
+-	unlink(sTestFileName);
++		unlink(sTestFileName);
+ #endif
++		free(sTestFileName);
++	}
+ }
+ 
+ void ensure (int condition, const char *message)
+@@ -127,7 +131,7 @@ int testmarkers (int fileformat)
+ 
+ int main (void)
+ {
+-	ensure(createTemporaryFile("testmarkers", sTestFileName),
++	ensure(createTemporaryFile("testmarkers", &sTestFileName),
+ 		"could not create temporary file");
+ 
+ 	testmarkers(AF_FILE_AIFF);
+--- a/test/twentyfour.c
++++ b/test/twentyfour.c
+@@ -71,8 +71,8 @@ int main (int argc, char **argv)
+ 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24);
+ 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);
+ 
+-	char testFileName[PATH_MAX];
+-	if (!createTemporaryFile("twentyfour", testFileName))
++	char *testFileName;
++	if (!createTemporaryFile("twentyfour", &testFileName))
+ 	{
+ 		fprintf(stderr, "could not create temporary file\n");
+ 		exit(EXIT_FAILURE);
+@@ -239,6 +239,7 @@ int main (int argc, char **argv)
+ 		exit(EXIT_FAILURE);
+ 	}
+ 	unlink(testFileName);
++	free(testFileName);
+ 
+ 	exit(EXIT_SUCCESS);
+ }
+--- a/test/twentyfour2.c
++++ b/test/twentyfour2.c
+@@ -45,15 +45,19 @@
+ 
+ #include "TestUtilities.h"
+ 
+-static char sTestFileName[PATH_MAX];
++static char *sTestFileName;
+ 
+ #define FRAME_COUNT 10000
+ 
+ void cleanup (void)
+ {
++	if (sTestFileName)
++	{
+ #ifndef DEBUG
+-	unlink(sTestFileName);
++		unlink(sTestFileName);
+ #endif
++		free(sTestFileName);
++	}
+ }
+ 
+ void ensure (int condition, const char *message)
+@@ -78,7 +82,7 @@ int main (void)
+ 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);
+ 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24);
+ 
+-	ensure(createTemporaryFile("twentyfour2", sTestFileName),
++	ensure(createTemporaryFile("twentyfour2", &sTestFileName),
+ 		"could not create temporary file");
+ 	file = afOpenFile(sTestFileName, "w", setup);
+ 	ensure(file != NULL, "could not open test file for writing");
+--- a/test/writealaw.c
++++ b/test/writealaw.c
+@@ -53,7 +53,7 @@
+ 
+ #include "TestUtilities.h"
+ 
+-static char sTestFileName[PATH_MAX];
++static char *sTestFileName;
+ 
+ #define FRAME_COUNT 16
+ #define SAMPLE_COUNT FRAME_COUNT
+@@ -62,9 +62,13 @@ void testalaw (int fileFormat);
+ 
+ void cleanup (void)
+ {
++	if (sTestFileName)
++	{
+ #ifndef DEBUG
+-	unlink(sTestFileName);
++		unlink(sTestFileName);
+ #endif
++		free(sTestFileName);
++	}
+ }
+ 
+ void ensure (int condition, const char *message)
+@@ -113,7 +117,7 @@ void testalaw (int fileFormat)
+ 	afInitFileFormat(setup, fileFormat);
+ 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);
+ 
+-	ensure(createTemporaryFile("writealaw", sTestFileName),
++	ensure(createTemporaryFile("writealaw", &sTestFileName),
+ 		"could not create temporary file");
+ 	file = afOpenFile(sTestFileName, "w", setup);
+ 	afFreeFileSetup(setup);
+--- a/test/writeraw.c
++++ b/test/writeraw.c
+@@ -44,13 +44,17 @@
+ 
+ #include "TestUtilities.h"
+ 
+-static char sTestFileName[PATH_MAX];
++static char *sTestFileName;
+ 
+ void cleanup (void)
+ {
++	if (sTestFileName)
++	{
+ #ifndef DEBUG
+-	unlink(sTestFileName);
++		unlink(sTestFileName);
+ #endif
++		free(sTestFileName);
++	}
+ }
+ 
+ void ensure (int condition, const char *message)
+@@ -84,7 +88,7 @@ int main (int argc, char **argv)
+ 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);
+ 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
+ 
+-	ensure(createTemporaryFile("writeraw", sTestFileName),
++	ensure(createTemporaryFile("writeraw", &sTestFileName),
+ 		"could not create temporary file");
+ 	file = afOpenFile(sTestFileName, "w", setup);
+ 	ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing");
+--- a/test/writeulaw.c
++++ b/test/writeulaw.c
+@@ -53,7 +53,7 @@
+ 
+ #include "TestUtilities.h"
+ 
+-static char sTestFileName[PATH_MAX];
++static char *sTestFileName;
+ 
+ #define FRAME_COUNT 16
+ #define SAMPLE_COUNT FRAME_COUNT
+@@ -62,9 +62,13 @@ void testulaw (int fileFormat);
+ 
+ void cleanup (void)
+ {
++	if (sTestFileName)
++	{
+ #ifndef DEBUG
+-	unlink(sTestFileName);
++		unlink(sTestFileName);
+ #endif
++		free(sTestFileName);
++	}
+ }
+ 
+ void ensure (int condition, const char *message)
+@@ -113,7 +117,7 @@ void testulaw (int fileFormat)
+ 	afInitFileFormat(setup, fileFormat);
+ 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);
+ 
+-	ensure(createTemporaryFile("writeulaw", sTestFileName),
++	ensure(createTemporaryFile("writeulaw", &sTestFileName),
+ 		"could not create temporary file");
+ 	file = afOpenFile(sTestFileName, "w", setup);
+ 	afFreeFileSetup(setup);
diff --git a/11_CVE-2018-13440.patch b/11_CVE-2018-13440.patch
new file mode 100644
index 0000000..ffd65b4
--- /dev/null
+++ b/11_CVE-2018-13440.patch
@@ -0,0 +1,28 @@
+From fde6d79fb8363c4a329a184ef0b107156602b225 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Thu, 27 Sep 2018 10:48:45 +0200
+Subject: [PATCH] ModuleState: handle compress/decompress init failure
+
+When 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
+---
+ libaudiofile/modules/ModuleState.cpp | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/libaudiofile/modules/ModuleState.cpp b/libaudiofile/modules/ModuleState.cpp
+index 0c29d7a..070fd9b 100644
+--- a/libaudiofile/modules/ModuleState.cpp
++++ b/libaudiofile/modules/ModuleState.cpp
+@@ -75,6 +75,9 @@ status ModuleState::initFileModule(AFfilehandle file, Track *track)
+ 		m_fileModule = unit->initcompress(track, file->m_fh, file->m_seekok,
+ 			file->m_fileFormat == AF_FILE_RAWDATA, &chunkFrames);
+ 
++	if (!m_fileModule)
++		return AF_FAIL;
++
+ 	if (unit->needsRebuffer)
+ 	{
+ 		assert(unit->nativeSampleFormat == AF_SAMPFMT_TWOSCOMP);
diff --git a/12_CVE-2018-17095.patch b/12_CVE-2018-17095.patch
new file mode 100644
index 0000000..231021b
--- /dev/null
+++ b/12_CVE-2018-17095.patch
@@ -0,0 +1,26 @@
+From 822b732fd31ffcb78f6920001e9b1fbd815fa712 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Thu, 27 Sep 2018 12:11:12 +0200
+Subject: [PATCH] SimpleModule: set output chunk framecount after pull
+
+After 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
+---
+ libaudiofile/modules/SimpleModule.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libaudiofile/modules/SimpleModule.cpp b/libaudiofile/modules/SimpleModule.cpp
+index 2bae1eb..e87932c 100644
+--- a/libaudiofile/modules/SimpleModule.cpp
++++ b/libaudiofile/modules/SimpleModule.cpp
+@@ -26,6 +26,7 @@
+ void SimpleModule::runPull()
+ {
+ 	pull(m_outChunk->frameCount);
++	m_outChunk->frameCount = m_inChunk->frameCount;
+ 	run(*m_inChunk, *m_outChunk);
+ }
+ 
diff --git a/PKGBUILD b/PKGBUILD
index 45ec9ab..3f6b3e9 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,16 +1,19 @@
-# Maintainer: Ray Rashif <schiv@archlinux.org>
+# Maintainer: David Runge <dave@sleepmap.de>
+# Contributor: Ray Rashif <schiv@archlinux.org>
 # Contributor: dorphell <dorphell@archlinux.org>
 
 pkgname=audiofile
 pkgver=0.3.6
-pkgrel=4
+pkgrel=5
 pkgdesc="Silicon Graphics Audio File Library"
 arch=('x86_64')
 url="https://audiofile.68k.org/"
-license=('LGPL')
+license=('GPL2' 'LGPL2.1')
 depends=('gcc-libs' 'alsa-lib' 'flac')
+provides=('libaudiofile.so')
 source=("https://audiofile.68k.org/$pkgname-$pkgver.tar.gz"
         01_gcc6.patch
+        02_hurd.patch
         03_CVE-2015-7747.patch
         04_clamp-index-values-to-fix-index-overflow-in-IMA.cpp.patch
         05_Always-check-the-number-of-coefficients.patch
@@ -18,42 +21,50 @@ source=("https://audiofile.68k.org/$pkgname-$pkgver.tar.gz"
         07_Check-for-multiplication-overflow-in-sfconvert.patch
         08_Fix-signature-of-multiplyCheckOverflow.-It-returns-a-b.patch
         09_Actually-fail-when-error-occurs-in-parseFormat.patch
-        10_Check-for-division-by-zero-in-BlockCodec-runPull.patch)
-sha256sums=('cdc60df19ab08bfe55344395739bb08f50fc15c92da3962fac334d3bff116965'
-            'a1904603c0292e76530f635dfc1828fb4e0d9d13555581cad33c0200640f7a27'
-            'bcfc180708d089b5abe0ae1439809b5a4306a08917b0212c3d135e5ec56711f2'
-            '540c517828d5573ba7bc3fd9b3811f39f4ea0132011d348d22bdfc545e865a8e'
-            '1b55abeb867d66b7d3b7c34585e77e6d3656c6317b582c99f3280d37523c7718'
-            '7a464eb7521ae8deb67516309bb396caa93135dc62fbad7351e67923b1766423'
-            '2ed5cc3b57394ea33ad466ca9844b766e4cb91dd7b1e2b71deaf15cf881dbf51'
-            '257f157cf2cc8947e0f5be4bff2c4afddbe73643e9e39a83171dbea02f5d52f4'
-            '48deaaa07bfade35208edb9e22b4fe78f91470012414ddb26cd68f684c95e33d'
-            'f31d51ebd8f8e0bd076cd1bce34b210c4dbbd959ca9b87693ad86a6399c492a3')
+        10_Check-for-division-by-zero-in-BlockCodec-runPull.patch
+        11_CVE-2018-13440.patch
+        12_CVE-2018-17095.patch)
+sha512sums=('f9a1182d93e405c21eba79c5cc40962347bff13f1b3b732d9a396e3d1675297515188bd6eb43033aaa00e9bde74ff4628c1614462456529cabba464f03c1d5fa'
+            'ae11735970eaddb664251614743cb46ae029b4073f4f8ea7cd4570d50c0f4b7f7b426399901b011d1ea799bb99d4ac648e76be97f13a51e32d7a63f97b38a89f'
+            '76ce5a29beaa394f3a24e7db7c40864f26119857e78087b6780853d06d4f44e80656c418b2c99d95224d29b69c23c51c54a4c8edac5dbaa4038a9d6c1ef7be06'
+            '7673ab3fafdb0dac514a42622f53ea17aa56836c76413e5680c475537e195c53df21f26da1bd4e7941df2dc8b33a471ab52d539dabffbaef8bc95ee59951e7fe'
+            'e7afe1a27566fb593ea53176256df23e447a2ee842cb4168930dec365fdabe7f2f43512d81bca5f14336ef0c756f6006c24948a3c2d79baafb0042ed8a145aae'
+            '187fb02a0d23390a62507756918c6f0b149570d7361bfe18944ea182adb966bb2bece93ed25eb6b38b61e252347cb68372c39ea948e094be7afea126d38115c0'
+            '2a81cd1e87976b0123de0638fe4a20a644bc3292f938def3f1de205296f86c0dc7dfbb78a7c8d75c9b9e771c2dc96708f45d9766cf25be2a11bac61285e7de7f'
+            '65e46f7c7e5c994d98e15ed6e94b9512650cf30d4a7fb213f27a177e38defdb0575faa74712d2ef1c3541db069f98b10f7f365ebb01304a0bcdc92552114d701'
+            '7c81e9dda0fc996a0c7a32da3f7480ddcb5cb30b1fd08c36d485021d699ab886732430271ac5a458c1d43dfb11fd0e97a4a9d7608c7f414eb23de59384b81a80'
+            '51c92ce66e987ae1d4bda65247134097705ef45cf7670401af7943bf6bbfc674089bcfafa49983046b10573ea72900adb96c296739c234d5e98539098eebe022'
+            '234b0b520eebccc8e7782735615ad8fb2f7c03937da2b7dec0b091ca35b8a542d4e5c7ad22ed6715f019cdb36992838d7458ef58980bfb4fa80062e764d18ae2'
+            'e29ab46b2edcbbeb048a7d9e6210d0faac8b75d9a48a663f62b37881e03d34fa97ffaa05d61da53b49404f60f0cadfcbbbb58438ae82af40dd37d0117bf8c631'
+            'ace83995606f900543f65ce6199fe1a69c757b7b37e92561be1c49c2f827676f888e36132ab3fedf3b9f77d4382ea933480fe326859c092aa95ba2c24e777363')
 
 prepare() {
-  cd $pkgname-$pkgver
-  patch -Np1 -i ../01_gcc6.patch
-  patch -Np1 -i ../03_CVE-2015-7747.patch
-  patch -Np1 -i ../04_clamp-index-values-to-fix-index-overflow-in-IMA.cpp.patch
-  patch -Np1 -i ../05_Always-check-the-number-of-coefficients.patch
-  patch -Np1 -i ../06_Check-for-multiplication-overflow-in-MSADPCM-decodeSam.patch
-  patch -Np1 -i ../07_Check-for-multiplication-overflow-in-sfconvert.patch
-  patch -Np1 -i ../08_Fix-signature-of-multiplyCheckOverflow.-It-returns-a-b.patch
-  patch -Np1 -i ../09_Actually-fail-when-error-occurs-in-parseFormat.patch
-  patch -Np1 -i ../10_Check-for-division-by-zero-in-BlockCodec-runPull.patch
+  cd "$pkgname-$pkgver"
+  local filename
+  for filename in "${source[@]}"; do
+    if [[ "$filename" =~ \.patch$ ]]; then
+      echo "Applying patch ${filename##*/}"
+      patch -p1 -N -i "$srcdir/${filename##*/}"
+    fi
+  done
+  autoreconf -vfi
 }
 
 build() {
-  cd "$srcdir/$pkgname-$pkgver"
-
+  cd "$pkgname-$pkgver"
   ./configure --prefix=/usr
   make
 }
 
-package() {
-  cd "$srcdir/$pkgname-$pkgver"
+check() {
+  cd "$pkgname-$pkgver"
+  make -k check
+}
 
+package() {
+  cd "$pkgname-$pkgver"
   make DESTDIR="$pkgdir" install
+  install -vDm 644 {AUTHORS,ChangeLog,NEWS,NOTES,README,TODO} \
+    -t "${pkgdir}/usr/share/doc/${pkgname}"
 }
-
 # vim:set ts=2 sw=2 et: