Ravenports generated: 18 Jan 2021 12:16
[ravenports.git] / bucket_C3 / audiofile
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               audiofile
4 VERSION=                0.3.6
5 KEYWORDS=               audio
6 VARIANTS=               standard
7 SDESC[standard]=        Library to handle various audio file formats
8 HOMEPAGE=               https://audiofile.68k.org/
9 CONTACT=                nobody
10
11 DOWNLOAD_GROUPS=        main
12 SITES[main]=            GNOME/audiofile/0.3
13 DISTFILE[1]=            audiofile-0.3.6.tar.xz:main
14 DF_INDEX=               1
15 SPKGS[standard]=        single
16
17 OPTIONS_AVAILABLE=      none
18 OPTIONS_STANDARD=       none
19
20 BUILDRUN_DEPENDS=       flac:primary:standard
21
22 USES=                   cpe pkgconfig libtool c++:single
23
24 LICENSE=                LGPL21+:single
25 LICENSE_TERMS=          single:{{WRKDIR}}/TERMS
26 LICENSE_FILE=           LGPL21+:{{WRKSRC}}/COPYING
27 LICENSE_SCHEME=         solo
28
29 FPC_EQUIVALENT=         audio/libaudiofile
30
31 MUST_CONFIGURE=         gnu
32
33 INSTALL_TARGET=         install-strip
34 SOVERSION=              1.0.0
35
36 post-extract:
37         # extract license terms
38         ${AWK} '/Audio File Library itself/,EOF' ${WRKSRC}/README\
39                 > ${WRKDIR}/TERMS
40
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.
44
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.
51
52 Supported file formats:
53 - AIFF/AIFF-C (.aiff, .aifc)
54 - WAVE (.wav)
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)
61 - NIST SPHERE (.wav)
62 - Core Audio Format (.caf)
63 - FLAC (.flac)
64
65 Supported compression formats:
66 - G.711 mu-law and A-law
67 - IMA ADPCM
68 - Microsoft ADPCM
69 - FLAC
70 - ALAC (Apple Lossless Audio Codec)
71
72
73 [FILE:101:distinfo]
74 ea2449ad3f201ec590d811db9da6d02ffc5e87a677d06b92ab15363d8cb59782       530760 audiofile-0.3.6.tar.xz
75
76
77 [FILE:924:manifests/plist.single]
78 bin/
79  sfconvert
80  sfinfo
81 include/
82  af_vfs.h
83  audiofile.h
84  aupvlist.h
85 lib/
86  libaudiofile.a
87  libaudiofile.so
88  libaudiofile.so.%%SOMAJOR%%
89  libaudiofile.so.%%SOVERSION%%
90 lib/pkgconfig/audiofile.pc
91 share/man/man1/
92  sfconvert.1.gz
93  sfinfo.1.gz
94 share/man/man3/
95  afCloseFile.3.gz
96  afGetDataOffset.3.gz
97  afGetFrameCount.3.gz
98  afGetFrameSize.3.gz
99  afGetTrackBytes.3.gz
100  afInitAESChannelData.3.gz
101  afInitAESChannelDataTo.3.gz
102  afInitByteOrder.3.gz
103  afInitChannels.3.gz
104  afInitCompression.3.gz
105  afInitFileFormat.3.gz
106  afInitRate.3.gz
107  afInitSampleFormat.3.gz
108  afNewFileSetup.3.gz
109  afOpenFile.3.gz
110  afQuery.3.gz
111  afQueryDouble.3.gz
112  afQueryLong.3.gz
113  afQueryPointer.3.gz
114  afReadFrames.3.gz
115  afReadMisc.3.gz
116  afSeekFrame.3.gz
117  afSeekMisc.3.gz
118  afSetErrorHandler.3.gz
119  afSetVirtualByteOrder.3.gz
120  afSetVirtualChannels.3.gz
121  afSetVirtualPCMMapping.3.gz
122  afSetVirtualSampleFormat.3.gz
123  afTellFrame.3.gz
124  afWriteFrames.3.gz
125  afWriteMisc.3.gz
126
127
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
133 ---
134 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
135
136 --- libaudiofile/modules/SimpleModule.h
137 +++ libaudiofile/modules/SimpleModule.h
138 @@ -123,7 +123,7 @@ struct signConverter
139         typedef typename IntTypes<Format>::UnsignedType UnsignedType;
140  
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);
144  
145         struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
146         {
147 --- test/FloatToInt.cpp
148 +++ test/FloatToInt.cpp
149 @@ -115,7 +115,7 @@ TEST_F(FloatToIntTest, Int16)
150                 EXPECT_EQ(readData[i], expectedData[i]);
151  }
152  
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;
156  
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]);
162  }
163  
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;
167  
168  TEST_F(IntToFloatTest, Int24)
169 --- test/NeXT.cpp
170 +++ test/NeXT.cpp
171 @@ -37,13 +37,13 @@
172  
173  #include "TestUtilities.h"
174  
175 -const char kDataUnspecifiedLength[] =
176 +const signed char kDataUnspecifiedLength[] =
177  {
178         '.', 's', 'n', 'd',
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
186         0, 1,
187         0, 1,
188 @@ -57,13 +57,13 @@ const char kDataUnspecifiedLength[] =
189         0, 55
190  };
191  
192 -const char kDataTruncated[] =
193 +const signed char kDataTruncated[] =
194  {
195         '.', 's', 'n', 'd',
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
202         0, 1,
203         0, 1,
204 @@ -152,13 +152,13 @@ TEST(NeXT, Truncated)
205         ASSERT_EQ(::unlink(testFileName.c_str()), 0);
206  }
207  
208 -const char kDataZeroChannels[] =
209 +const signed char kDataZeroChannels[] =
210  {
211         '.', 's', 'n', 'd',
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
218         0, 1
219  };
220 --- test/Sign.cpp
221 +++ test/Sign.cpp
222 @@ -116,7 +116,7 @@ TEST_F(SignConversionTest, Int16)
223                 EXPECT_EQ(readData[i], expectedData[i]);
224  }
225  
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;
230  
231
232
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
240 ---
241 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
242
243 --- test/TestUtilities.cpp
244 +++ test/TestUtilities.cpp
245 @@ -21,8 +21,8 @@
246  #include "TestUtilities.h"
247  
248  #include <limits.h>
249 -#include <stdio.h>
250  #include <stdlib.h>
251 +#include <string.h>
252  #include <unistd.h>
253  
254  bool createTemporaryFile(const std::string &prefix, std::string *path)
255 @@ -35,12 +35,12 @@ bool createTemporaryFile(const std::stri
256         return true;
257  }
258  
259 -bool createTemporaryFile(const char *prefix, char *path)
260 +bool createTemporaryFile(const char *prefix, char **path)
261  {
262 -       snprintf(path, PATH_MAX, "/tmp/%s-XXXXXX", prefix);
263 -       int fd = ::mkstemp(path);
264 -       if (fd < 0)
265 -               return false;
266 -       ::close(fd);
267 -       return true;
268 +       *path = NULL;
269 +       std::string pathString;
270 +       bool result = createTemporaryFile(prefix, &pathString);
271 +       if (result)
272 +               *path = ::strdup(pathString.c_str());
273 +       return result;
274  }
275 --- test/TestUtilities.h
276 +++ test/TestUtilities.h
277 @@ -53,7 +53,7 @@ extern "C" {
278  
279  #include <stdbool.h>
280  
281 -bool createTemporaryFile(const char *prefix, char *path);
282 +bool createTemporaryFile(const char *prefix, char **path);
283  
284  #ifdef __cplusplus
285  }
286 --- test/floatto24.c
287 +++ test/floatto24.c
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);
291  
292 -       char testFileName[PATH_MAX];
293 -       if (!createTemporaryFile("floatto24", testFileName))
294 +       char *testFileName;
295 +       if (!createTemporaryFile("floatto24", &testFileName))
296         {
297                 fprintf(stderr, "Could not create temporary file.\n");
298                 exit(EXIT_FAILURE);
299 @@ -182,6 +182,7 @@ int main (int argc, char **argv)
300         }
301  
302         unlink(testFileName);
303 +       free(testFileName);
304  
305         exit(EXIT_SUCCESS);
306  }
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);
312  
313 -       char testFileName[PATH_MAX];
314 -       if (!createTemporaryFile("sixteen-to-eight", testFileName))
315 +       char *testFileName;
316 +       if (!createTemporaryFile("sixteen-to-eight", &testFileName))
317         {
318                 fprintf(stderr, "Could not create temporary file.\n");
319                 exit(EXIT_FAILURE);
320 @@ -113,6 +113,7 @@ int main (int argc, char **argv)
321  
322         afCloseFile(file);
323         unlink(testFileName);
324 +       free(testFileName);
325  
326         exit(EXIT_SUCCESS);
327  }
328 --- test/testchannelmatrix.c
329 +++ test/testchannelmatrix.c
330 @@ -39,7 +39,7 @@
331  
332  #include "TestUtilities.h"
333  
334 -static char sTestFileName[PATH_MAX];
335 +static char *sTestFileName;
336  
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,
340  
341  void cleanup (void)
342  {
343 -       unlink(sTestFileName);
344 +       if (sTestFileName)
345 +       {
346 +               unlink(sTestFileName);
347 +               free(sTestFileName);
348 +       }
349  }
350  
351  void ensure (int condition, const char *message)
352 @@ -76,7 +80,7 @@ int main (void)
353         afInitFileFormat(setup, AF_FILE_AIFFC);
354  
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
363 @@ -38,7 +38,7 @@
364  
365  #include "TestUtilities.h"
366  
367 -static char sTestFileName[PATH_MAX];
368 +static char *sTestFileName;
369  
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);
373  
374  void cleanup (void)
375  {
376 -       unlink(sTestFileName);
377 +       if (sTestFileName)
378 +       {
379 +               unlink(sTestFileName);
380 +               free(sTestFileName);
381 +       }
382  }
383  
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);
388  
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");
394 --- test/testfloat.c
395 +++ test/testfloat.c
396 @@ -38,7 +38,7 @@
397  
398  #include "TestUtilities.h"
399  
400 -static char sTestFileName[PATH_MAX];
401 +static char *sTestFileName;
402  
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);
406  
407  void cleanup (void)
408  {
409 -       unlink(sTestFileName);
410 +       if (sTestFileName)
411 +       {
412 +               unlink(sTestFileName);
413 +               free(sTestFileName);
414 +       }
415  }
416  
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);
421  
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
429 @@ -32,15 +32,19 @@
430  
431  #include "TestUtilities.h"
432  
433 -static char sTestFileName[PATH_MAX];
434 +static char *sTestFileName;
435  
436  #define FRAME_COUNT 200
437  
438  void cleanup (void)
439  {
440 +       if (sTestFileName)
441 +       {
442  #ifndef DEBUG
443 -       unlink(sTestFileName);
444 +               unlink(sTestFileName);
445  #endif
446 +               free(sTestFileName);
447 +       }
448  }
449  
450  void ensure (int condition, const char *message)
451 @@ -127,7 +131,7 @@ int testmarkers (int fileformat)
452  
453  int main (void)
454  {
455 -       ensure(createTemporaryFile("testmarkers", sTestFileName),
456 +       ensure(createTemporaryFile("testmarkers", &sTestFileName),
457                 "could not create temporary file");
458  
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);
465  
466 -       char testFileName[PATH_MAX];
467 -       if (!createTemporaryFile("twentyfour", testFileName))
468 +       char *testFileName;
469 +       if (!createTemporaryFile("twentyfour", &testFileName))
470         {
471                 fprintf(stderr, "could not create temporary file\n");
472                 exit(EXIT_FAILURE);
473 @@ -239,6 +239,7 @@ int main (int argc, char **argv)
474                 exit(EXIT_FAILURE);
475         }
476         unlink(testFileName);
477 +       free(testFileName);
478  
479         exit(EXIT_SUCCESS);
480  }
481 --- test/twentyfour2.c
482 +++ test/twentyfour2.c
483 @@ -45,15 +45,19 @@
484  
485  #include "TestUtilities.h"
486  
487 -static char sTestFileName[PATH_MAX];
488 +static char *sTestFileName;
489  
490  #define FRAME_COUNT 10000
491  
492  void cleanup (void)
493  {
494 +       if (sTestFileName)
495 +       {
496  #ifndef DEBUG
497 -       unlink(sTestFileName);
498 +               unlink(sTestFileName);
499  #endif
500 +               free(sTestFileName);
501 +       }
502  }
503  
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);
508  
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");
514 --- test/writealaw.c
515 +++ test/writealaw.c
516 @@ -53,7 +53,7 @@
517  
518  #include "TestUtilities.h"
519  
520 -static char sTestFileName[PATH_MAX];
521 +static char *sTestFileName;
522  
523  #define FRAME_COUNT 16
524  #define SAMPLE_COUNT FRAME_COUNT
525 @@ -62,9 +62,13 @@ void testalaw (int fileFormat);
526  
527  void cleanup (void)
528  {
529 +       if (sTestFileName)
530 +       {
531  #ifndef DEBUG
532 -       unlink(sTestFileName);
533 +               unlink(sTestFileName);
534  #endif
535 +               free(sTestFileName);
536 +       }
537  }
538  
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);
543  
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);
549 --- test/writeraw.c
550 +++ test/writeraw.c
551 @@ -44,13 +44,17 @@
552  
553  #include "TestUtilities.h"
554  
555 -static char sTestFileName[PATH_MAX];
556 +static char *sTestFileName;
557  
558  void cleanup (void)
559  {
560 +       if (sTestFileName)
561 +       {
562  #ifndef DEBUG
563 -       unlink(sTestFileName);
564 +               unlink(sTestFileName);
565  #endif
566 +               free(sTestFileName);
567 +       }
568  }
569  
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);
574  
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");
580 --- test/writeulaw.c
581 +++ test/writeulaw.c
582 @@ -53,7 +53,7 @@
583  
584  #include "TestUtilities.h"
585  
586 -static char sTestFileName[PATH_MAX];
587 +static char *sTestFileName;
588  
589  #define FRAME_COUNT 16
590  #define SAMPLE_COUNT FRAME_COUNT
591 @@ -62,9 +62,13 @@ void testulaw (int fileFormat);
592  
593  void cleanup (void)
594  {
595 +       if (sTestFileName)
596 +       {
597  #ifndef DEBUG
598 -       unlink(sTestFileName);
599 +               unlink(sTestFileName);
600  #endif
601 +               free(sTestFileName);
602 +       }
603  }
604  
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);
609  
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);
615
616
617 [FILE:4290:patches/patch-03_CVE-2015-7747]
618 Description: fix buffer overflow when changing both sample format and
619  number of channels
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
623
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));
628  
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));
635 --- test/Makefile.am
636 +++ test/Makefile.am
637 @@ -26,6 +26,7 @@ TESTS = \
638         VirtualFile \
639         floatto24 \
640         query2 \
641 +       sixteen-stereo-to-eight-mono \
642         sixteen-to-eight \
643         testchannelmatrix \
644         testdouble \
645 @@ -139,6 +140,7 @@ printmarkers_SOURCES = printmarkers.c
646  printmarkers_LDADD = $(LIBAUDIOFILE) -lm
647  
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
650  
651  testchannelmatrix_SOURCES = testchannelmatrix.c TestUtilities.cpp TestUtilities.h
652  
653 --- /dev/null
654 +++ test/sixteen-stereo-to-eight-mono.c
655 @@ -0,0 +1,118 @@
656 +/*
657 +       Audio File Library
658 +
659 +       Copyright 2000, Silicon Graphics, Inc.
660 +
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.
665 +
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.
670 +
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.
674 +*/
675 +
676 +/*
677 +       sixteen-stereo-to-eight-mono.c
678 +
679 +       This program tests the conversion from 2-channel 16-bit integers to
680 +       1-channel 8-bit integers.
681 +*/
682 +
683 +#ifdef HAVE_CONFIG_H
684 +#include <config.h>
685 +#endif
686 +
687 +#include <stdint.h>
688 +#include <stdio.h>
689 +#include <stdlib.h>
690 +#include <string.h>
691 +#include <unistd.h>
692 +#include <limits.h>
693 +
694 +#include <audiofile.h>
695 +
696 +#include "TestUtilities.h"
697 +
698 +int main (int argc, char **argv)
699 +{
700 +       AFfilehandle file;
701 +       AFfilesetup setup;
702 +       int16_t frames16[] = {14298, 392, 3923, -683, 958, -1921};
703 +       int8_t frames8[] = {28, 6, -2};
704 +       int i, frameCount = 3;
705 +       int8_t byte;
706 +       AFframecount result;
707 +
708 +       setup = afNewFileSetup();
709 +
710 +       afInitFileFormat(setup, AF_FILE_WAVE);
711 +
712 +       afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
713 +       afInitChannels(setup, AF_DEFAULT_TRACK, 2);
714 +
715 +       char *testFileName;
716 +       if (!createTemporaryFile("sixteen-to-eight", &testFileName))
717 +       {
718 +               fprintf(stderr, "Could not create temporary file.\n");
719 +               exit(EXIT_FAILURE);
720 +       }
721 +
722 +       file = afOpenFile(testFileName, "w", setup);
723 +       if (file == AF_NULL_FILEHANDLE)
724 +       {
725 +               fprintf(stderr, "could not open file for writing\n");
726 +               exit(EXIT_FAILURE);
727 +       }
728 +
729 +       afFreeFileSetup(setup);
730 +
731 +       afWriteFrames(file, AF_DEFAULT_TRACK, frames16, frameCount);
732 +
733 +       afCloseFile(file);
734 +
735 +       file = afOpenFile(testFileName, "r", AF_NULL_FILESETUP);
736 +       if (file == AF_NULL_FILEHANDLE)
737 +       {
738 +               fprintf(stderr, "could not open file for reading\n");
739 +               exit(EXIT_FAILURE);
740 +       }
741 +
742 +       afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 8);
743 +       afSetVirtualChannels(file, AF_DEFAULT_TRACK, 1);
744 +
745 +       for (i=0; i<frameCount; i++)
746 +       {
747 +               /* Read one frame. */
748 +               result = afReadFrames(file, AF_DEFAULT_TRACK, &byte, 1);
749 +
750 +               if (result != 1)
751 +                       break;
752 +
753 +               /* Compare the byte read with its precalculated value. */
754 +               if (memcmp(&byte, &frames8[i], 1) != 0)
755 +               {
756 +                       printf("error\n");
757 +                       printf("expected %d, got %d\n", frames8[i], byte);
758 +                       exit(EXIT_FAILURE);
759 +               }
760 +               else
761 +               {
762 +#ifdef DEBUG
763 +                       printf("got what was expected: %d\n", byte);
764 +#endif
765 +               }
766 +       }
767 +
768 +       afCloseFile(file);
769 +       unlink(testFileName);
770 +       free(testFileName);
771 +
772 +       exit(EXIT_SUCCESS);
773 +}
774
775
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
780
781 This fixes #33
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/)
784 ---
785  libaudiofile/modules/IMA.cpp | 4 ++--
786  1 file changed, 2 insertions(+), 2 deletions(-)
787
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;
793  
794 -               m_adpcmState[c].index = encoded[2];
795 +               m_adpcmState[c].index = clamp(encoded[2], 0, 88);
796  
797                 *decoded++ = m_adpcmState[c].previousValue;
798  
799 @@ -210,7 +210,7 @@ int IMA::decodeBlockQT(const uint8_t *encoded, int16_t *decoded)
800                         predictor -= 0x10000;
801  
802                 state.previousValue = clamp(predictor, MIN_INT16, MAX_INT16);
803 -               state.index = encoded[1] & 0x7f;
804 +               state.index = clamp(encoded[1] & 0x7f, 0, 88);
805                 encoded += 2;
806  
807                 for (int n=0; n<m_framesPerPacket; n+=2)
808
809
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
814
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.
818
819 This fixes the 00191-audiofile-indexoob issue in #41
820 ---
821  libaudiofile/WAVE.cpp | 6 ++++++
822  1 file changed, 6 insertions(+)
823
824 --- libaudiofile/WAVE.cpp
825 +++ libaudiofile/WAVE.cpp
826 @@ -281,6 +281,12 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
827  
828                         /* numCoefficients should be at least 7. */
829                         assert(numCoefficients >= 7 && numCoefficients <= 255);
830 +                       if (numCoefficients < 7 || numCoefficients > 255)
831 +                       {
832 +                               _af_error(AF_BAD_HEADER,
833 +                                               "Bad number of coefficients");
834 +                               return AF_FAIL;
835 +                       }
836  
837                         m_msadpcmNumCoefficients = numCoefficients;
838  
839
840
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
845
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.
849
850 This fixes the 00193-audiofile-signintoverflow-MSADPCM case of #41
851 ---
852  libaudiofile/modules/BlockCodec.cpp |  5 ++--
853  libaudiofile/modules/MSADPCM.cpp    | 47 +++++++++++++++++++++++++++++++++----
854  2 files changed, 46 insertions(+), 6 deletions(-)
855
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++)
861         {
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)
866 +                       break;
867  
868                 framesRead += m_framesPerPacket;
869         }
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
874  };
875  
876 +int firstBitSet(int x)
877 +{
878 +        int position=0;
879 +        while (x!=0)
880 +        {
881 +                x>>=1;
882 +                ++position;
883 +        }
884 +        return position;
885 +}
886 +
887 +#ifndef __has_builtin
888 +#define __has_builtin(x) 0
889 +#endif
890 +
891 +int multiplyCheckOverflow(int a, int b, int *result)
892 +{
893 +#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
894 +       return __builtin_mul_overflow(a, b, result);
895 +#else
896 +       if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits
897 +               return true;
898 +       *result = a * b;
899 +       return false;
900 +#endif
901 +}
902 +
903 +
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)
908  {
909         int linearSample = (state.sample1 * coefficient[0] +
910                 state.sample2 * coefficient[1]) >> 8;
911 +       int delta;
912  
913         linearSample += ((code & 0x08) ? (code - 0x10) : code) * state.delta;
914  
915         linearSample = clamp(linearSample, MIN_INT16, MAX_INT16);
916  
917 -       int delta = (state.delta * adaptationTable[code]) >> 8;
918 +       if (multiplyCheckOverflow(state.delta, adaptationTable[code], &delta))
919 +       {
920 +                if (ok) *ok=false;
921 +               _af_error(AF_BAD_COMPRESSION, "Error decoding sample");
922 +               return 0;
923 +       }
924 +       delta >>= 8;
925         if (delta < 16)
926                 delta = 16;
927  
928         state.delta = delta;
929         state.sample2 = state.sample1;
930         state.sample1 = linearSample;
931 +       if (ok) *ok=true;
932  
933         return static_cast<int16_t>(linearSample);
934  }
935 @@ -212,13 +248,16 @@ int MSADPCM::decodeBlock(const uint8_t *encoded, int16_t *decoded)
936         {
937                 uint8_t code;
938                 int16_t newSample;
939 +               bool ok;
940  
941                 code = *encoded >> 4;
942 -               newSample = decodeSample(*state[0], code, coefficient[0]);
943 +               newSample = decodeSample(*state[0], code, coefficient[0], &ok);
944 +               if (!ok) return 0;
945                 *decoded++ = newSample;
946  
947                 code = *encoded & 0x0f;
948 -               newSample = decodeSample(*state[1], code, coefficient[1]);
949 +               newSample = decodeSample(*state[1], code, coefficient[1], &ok);
950 +               if (!ok) return 0;
951                 *decoded++ = newSample;
952  
953                 encoded++;
954
955
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
960
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.
964
965 This fixes the 00192-audiofile-signintoverflow-sfconvert case
966 in #41
967 ---
968  sfcommands/sfconvert.c | 34 ++++++++++++++++++++++++++++++++--
969  1 file changed, 32 insertions(+), 2 deletions(-)
970
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);
976  
977 +int firstBitSet(int x)
978 +{
979 +        int position=0;
980 +        while (x!=0)
981 +        {
982 +                x>>=1;
983 +                ++position;
984 +        }
985 +        return position;
986 +}
987 +
988 +#ifndef __has_builtin
989 +#define __has_builtin(x) 0
990 +#endif
991 +
992 +int multiplyCheckOverflow(int a, int b, int *result)
993 +{
994 +#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
995 +       return __builtin_mul_overflow(a, b, result);
996 +#else
997 +       if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits
998 +               return true;
999 +       *result = a * b;
1000 +       return false;
1001 +#endif
1002 +}
1003 +
1004  int main (int argc, char **argv)
1005  {
1006         if (argc == 2)
1007 @@ -323,8 +350,11 @@ bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid)
1008  {
1009         int frameSize = afGetVirtualFrameSize(infile, trackid, 1);
1010  
1011 -       const int kBufferFrameCount = 65536;
1012 -       void *buffer = malloc(kBufferFrameCount * frameSize);
1013 +       int kBufferFrameCount = 65536;
1014 +       int bufferSize;
1015 +       while (multiplyCheckOverflow(kBufferFrameCount, frameSize, &bufferSize))
1016 +               kBufferFrameCount /= 2;
1017 +       void *buffer = malloc(bufferSize);
1018  
1019         AFframecount totalFrames = afGetFrameCount(infile, AF_DEFAULT_TRACK);
1020         AFframecount totalFramesWritten = 0;
1021
1022
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
1027
1028 ---
1029  libaudiofile/modules/MSADPCM.cpp | 2 +-
1030  sfcommands/sfconvert.c           | 2 +-
1031  2 files changed, 2 insertions(+), 2 deletions(-)
1032
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
1037  #endif
1038  
1039 -int multiplyCheckOverflow(int a, int b, int *result)
1040 +bool multiplyCheckOverflow(int a, int b, int *result)
1041  {
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
1048  #endif
1049  
1050 -int multiplyCheckOverflow(int a, int b, int *result)
1051 +bool multiplyCheckOverflow(int a, int b, int *result)
1052  {
1053  #if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
1054         return __builtin_mul_overflow(a, b, result);
1055
1056
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
1061
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.
1065
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/
1069 )
1070 ---
1071  libaudiofile/WAVE.cpp | 2 ++
1072  1 file changed, 2 insertions(+)
1073
1074 --- libaudiofile/WAVE.cpp
1075 +++ libaudiofile/WAVE.cpp
1076 @@ -332,6 +332,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
1077                         {
1078                                 _af_error(AF_BAD_NOT_IMPLEMENTED,
1079                                         "IMA ADPCM compression supports only 4 bits per sample");
1080 +                               return AF_FAIL;
1081                         }
1082  
1083                         int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
1084 @@ -339,6 +340,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
1085                         {
1086                                 _af_error(AF_BAD_CODEC_CONFIG,
1087                                         "Invalid samples per block for IMA ADPCM compression");
1088 +                               return AF_FAIL;
1089                         }
1090  
1091                         track->f.sampleWidth = 16;
1092
1093
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
1098
1099 ---
1100  libaudiofile/modules/BlockCodec.cpp | 2 +-
1101  1 file changed, 1 insertion(+), 1 deletion(-)
1102
1103 --- libaudiofile/modules/BlockCodec.cpp
1104 +++ libaudiofile/modules/BlockCodec.cpp
1105 @@ -47,7 +47,7 @@ void BlockCodec::runPull()
1106  
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;
1111  
1112         // Decompress into m_outChunk.
1113         for (int i=0; i<blocksRead; i++)
1114
1115
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
1121
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.
1125
1126 Fixes #49
1127 ---
1128  libaudiofile/modules/ModuleState.cpp | 3 +++
1129  1 file changed, 3 insertions(+)
1130
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);
1136  
1137 +       if (!m_fileModule)
1138 +               return AF_FAIL;
1139 +
1140         if (unit->needsRebuffer)
1141         {
1142                 assert(unit->nativeSampleFormat == AF_SAMPFMT_TWOSCOMP);
1143
1144
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
1150
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
1153 frame count.
1154
1155 Fixes #50 and #51
1156 ---
1157  libaudiofile/modules/SimpleModule.cpp | 1 +
1158  1 file changed, 1 insertion(+)
1159
1160 --- libaudiofile/modules/SimpleModule.cpp
1161 +++ libaudiofile/modules/SimpleModule.cpp
1162 @@ -26,6 +26,7 @@
1163  void SimpleModule::runPull()
1164  {
1165         pull(m_outChunk->frameCount);
1166 +       m_outChunk->frameCount = m_inChunk->frameCount;
1167         run(*m_inChunk, *m_outChunk);
1168  }
1169  
1170
1171
1172 [FILE:435:patches/patch-configure]
1173 --- configure.orig      2013-03-07 07:27:14 UTC
1174 +++ configure
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; }
1178  case "$host_os" in
1179 -  linux*)
1180 -    TEST_BIN="linuxtest alsaplay"
1181 -    platform=linux
1182 -    ;;
1183    irix5* | irix6*)
1184      TEST_BIN="irixread irixtestloop"
1185      platform=irix
1186