commit ba3c548d39b6e86012628e10022fcd232918cb14 Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 10:31:49 2019 -0400 Package init diff --git a/audiofile-0.3.6-CVE-2015-7747.patch b/audiofile-0.3.6-CVE-2015-7747.patch new file mode 100644 index 0000000..fae65f6 --- /dev/null +++ b/audiofile-0.3.6-CVE-2015-7747.patch @@ -0,0 +1,12 @@ +diff -Nurb --strip-trailing-cr audiofile-0.3.6-orig/libaudiofile/modules/ModuleState.cpp audiofile-0.3.6/libaudiofile/modules/ModuleState.cpp +--- audiofile-0.3.6-orig/libaudiofile/modules/ModuleState.cpp 2013-03-06 06:30:03.000000000 +0100 ++++ audiofile-0.3.6/libaudiofile/modules/ModuleState.cpp 2015-10-08 11:29:51.846082162 +0200 +@@ -402,7 +402,7 @@ + addModule(new Transform(outfc, in.pcm, out.pcm)); + + if (in.channelCount != out.channelCount) +- addModule(new ApplyChannelMatrix(infc, isReading, ++ addModule(new ApplyChannelMatrix(outfc, isReading, + in.channelCount, out.channelCount, + in.pcm.minClip, in.pcm.maxClip, + track->channelMatrix)); diff --git a/audiofile-0.3.6-left-shift-neg.patch b/audiofile-0.3.6-left-shift-neg.patch new file mode 100644 index 0000000..deef23c --- /dev/null +++ b/audiofile-0.3.6-left-shift-neg.patch @@ -0,0 +1,48 @@ +diff -Nurb --strip-trailing-cr audiofile-0.3.6-orig/libaudiofile/modules/SimpleModule.h audiofile-0.3.6/libaudiofile/modules/SimpleModule.h +--- audiofile-0.3.6-orig/libaudiofile/modules/SimpleModule.h 2013-03-06 06:30:03.000000000 +0100 ++++ audiofile-0.3.6/libaudiofile/modules/SimpleModule.h 2016-02-03 21:19:43.065454454 +0100 +@@ -123,7 +123,7 @@ + typedef typename IntTypes::UnsignedType UnsignedType; + + static const int kScaleBits = (Format + 1) * CHAR_BIT - 1; +- static const int kMinSignedValue = -1 << kScaleBits; ++ static const int kMinSignedValue = 0-(1U< + { +diff -Nurb --strip-trailing-cr audiofile-0.3.6-orig/test/FloatToInt.cpp audiofile-0.3.6/test/FloatToInt.cpp +--- audiofile-0.3.6-orig/test/FloatToInt.cpp 2013-02-11 18:23:26.000000000 +0100 ++++ audiofile-0.3.6/test/FloatToInt.cpp 2016-02-03 21:21:14.714510229 +0100 +@@ -115,7 +115,7 @@ + EXPECT_EQ(readData[i], expectedData[i]); + } + +-static const int32_t kMinInt24 = -1<<23; ++static const int32_t kMinInt24 = 0-(1U<<23); + static const int32_t kMaxInt24 = (1<<23) - 1; + + TEST_F(FloatToIntTest, Int24) +diff -Nurb --strip-trailing-cr audiofile-0.3.6-orig/test/IntToFloat.cpp audiofile-0.3.6/test/IntToFloat.cpp +--- audiofile-0.3.6-orig/test/IntToFloat.cpp 2013-02-11 18:23:26.000000000 +0100 ++++ audiofile-0.3.6/test/IntToFloat.cpp 2016-02-03 21:20:57.380445355 +0100 +@@ -117,7 +117,7 @@ + EXPECT_EQ(readData[i], expectedData[i]); + } + +-static const int32_t kMinInt24 = -1<<23; ++static const int32_t kMinInt24 = 0-(1U<<23); + static const int32_t kMaxInt24 = (1<<23) - 1; + + TEST_F(IntToFloatTest, Int24) +diff -Nurb --strip-trailing-cr audiofile-0.3.6-orig/test/Sign.cpp audiofile-0.3.6/test/Sign.cpp +--- audiofile-0.3.6-orig/test/Sign.cpp 2013-02-11 18:23:26.000000000 +0100 ++++ audiofile-0.3.6/test/Sign.cpp 2016-02-03 21:20:38.742450826 +0100 +@@ -116,7 +116,7 @@ + EXPECT_EQ(readData[i], expectedData[i]); + } + +-static const int32_t kMinInt24 = -1<<23; ++static const int32_t kMinInt24 = 0-(1U<<23); + static const int32_t kMaxInt24 = (1<<23) - 1; + static const uint32_t kMaxUInt24 = (1<<24) - 1; + diff --git a/audiofile-0.3.6-narrowing.patch b/audiofile-0.3.6-narrowing.patch new file mode 100644 index 0000000..f701d89 --- /dev/null +++ b/audiofile-0.3.6-narrowing.patch @@ -0,0 +1,52 @@ +diff -Nur audiofile-0.3.6-orig/test/NeXT.cpp audiofile-0.3.6/test/NeXT.cpp +--- audiofile-0.3.6-orig/test/NeXT.cpp 2013-02-11 18:23:26.000000000 +0100 ++++ audiofile-0.3.6/test/NeXT.cpp 2016-02-04 10:37:32.457140823 +0100 +@@ -37,13 +37,13 @@ + + #include "TestUtilities.h" + +-const char kDataUnspecifiedLength[] = ++const signed char kDataUnspecifiedLength[] = + { + '.', 's', 'n', 'd', + 0, 0, 0, 24, // offset of 24 bytes +- 0xff, 0xff, 0xff, 0xff, // unspecified length ++ -1, -1, -1, -1, // unspecified length + 0, 0, 0, 3, // 16-bit linear +- 0, 0, 172, 68, // 44100 Hz ++ 0, 0, -84, 68, // 44100 Hz (0xAC44) + 0, 0, 0, 1, // 1 channel + 0, 1, + 0, 1, +@@ -57,13 +57,13 @@ + 0, 55 + }; + +-const char kDataTruncated[] = ++const signed char kDataTruncated[] = + { + '.', 's', 'n', 'd', + 0, 0, 0, 24, // offset of 24 bytes + 0, 0, 0, 20, // length of 20 bytes + 0, 0, 0, 3, // 16-bit linear +- 0, 0, 172, 68, // 44100 Hz ++ 0, 0, -84, 68, // 44100 Hz (0xAC44) + 0, 0, 0, 1, // 1 channel + 0, 1, + 0, 1, +@@ -152,13 +152,13 @@ + ASSERT_EQ(::unlink(testFileName.c_str()), 0); + } + +-const char kDataZeroChannels[] = ++const signed char kDataZeroChannels[] = + { + '.', 's', 'n', 'd', + 0, 0, 0, 24, // offset of 24 bytes + 0, 0, 0, 2, // 2 bytes + 0, 0, 0, 3, // 16-bit linear +- 0, 0, 172, 68, // 44100 Hz ++ 0, 0, -84, 68, // 44100 Hz (0xAC44) + 0, 0, 0, 0, // 0 channels + 0, 1 + }; diff --git a/audiofile-0.3.6-pull42.patch b/audiofile-0.3.6-pull42.patch new file mode 100644 index 0000000..3fab300 --- /dev/null +++ b/audiofile-0.3.6-pull42.patch @@ -0,0 +1,176 @@ +diff -Nur audiofile-0.3.6/libaudiofile/modules/BlockCodec.cpp audiofile-0.3.6-pull42/libaudiofile/modules/BlockCodec.cpp +--- audiofile-0.3.6/libaudiofile/modules/BlockCodec.cpp 2013-03-06 06:30:03.000000000 +0100 ++++ audiofile-0.3.6-pull42/libaudiofile/modules/BlockCodec.cpp 2017-03-10 15:40:02.000000000 +0100 +@@ -52,8 +52,9 @@ + // Decompress into m_outChunk. + for (int i=0; i(m_inChunk->buffer) + i * m_bytesPerPacket, +- static_cast(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount); ++ if (decodeBlock(static_cast(m_inChunk->buffer) + i * m_bytesPerPacket, ++ static_cast(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount)==0) ++ break; + + framesRead += m_framesPerPacket; + } +diff -Nur audiofile-0.3.6/libaudiofile/modules/MSADPCM.cpp audiofile-0.3.6-pull42/libaudiofile/modules/MSADPCM.cpp +--- audiofile-0.3.6/libaudiofile/modules/MSADPCM.cpp 2013-03-06 06:30:03.000000000 +0100 ++++ audiofile-0.3.6-pull42/libaudiofile/modules/MSADPCM.cpp 2017-03-10 15:40:02.000000000 +0100 +@@ -101,24 +101,60 @@ + 768, 614, 512, 409, 307, 230, 230, 230 + }; + ++int firstBitSet(int x) ++{ ++ int position=0; ++ while (x!=0) ++ { ++ x>>=1; ++ ++position; ++ } ++ return position; ++} ++ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++bool multiplyCheckOverflow(int a, int b, int *result) ++{ ++#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow)) ++ return __builtin_mul_overflow(a, b, result); ++#else ++ if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits ++ return true; ++ *result = a * b; ++ return false; ++#endif ++} ++ ++ + // Compute a linear PCM value from the given differential coded value. + static int16_t decodeSample(ms_adpcm_state &state, +- uint8_t code, const int16_t *coefficient) ++ uint8_t code, const int16_t *coefficient, bool *ok=NULL) + { + int linearSample = (state.sample1 * coefficient[0] + + state.sample2 * coefficient[1]) >> 8; ++ int delta; + + linearSample += ((code & 0x08) ? (code - 0x10) : code) * state.delta; + + linearSample = clamp(linearSample, MIN_INT16, MAX_INT16); + +- int delta = (state.delta * adaptationTable[code]) >> 8; ++ if (multiplyCheckOverflow(state.delta, adaptationTable[code], &delta)) ++ { ++ if (ok) *ok=false; ++ _af_error(AF_BAD_COMPRESSION, "Error decoding sample"); ++ return 0; ++ } ++ delta >>= 8; + if (delta < 16) + delta = 16; + + state.delta = delta; + state.sample2 = state.sample1; + state.sample1 = linearSample; ++ if (ok) *ok=true; + + return static_cast(linearSample); + } +@@ -212,13 +248,16 @@ + { + uint8_t code; + int16_t newSample; ++ bool ok; + + code = *encoded >> 4; +- newSample = decodeSample(*state[0], code, coefficient[0]); ++ newSample = decodeSample(*state[0], code, coefficient[0], &ok); ++ if (!ok) return 0; + *decoded++ = newSample; + + code = *encoded & 0x0f; +- newSample = decodeSample(*state[1], code, coefficient[1]); ++ newSample = decodeSample(*state[1], code, coefficient[1], &ok); ++ if (!ok) return 0; + *decoded++ = newSample; + + encoded++; +diff -Nur audiofile-0.3.6/libaudiofile/WAVE.cpp audiofile-0.3.6-pull42/libaudiofile/WAVE.cpp +--- audiofile-0.3.6/libaudiofile/WAVE.cpp 2013-03-06 06:30:03.000000000 +0100 ++++ audiofile-0.3.6-pull42/libaudiofile/WAVE.cpp 2017-03-10 15:40:02.000000000 +0100 +@@ -281,6 +281,12 @@ + + /* numCoefficients should be at least 7. */ + assert(numCoefficients >= 7 && numCoefficients <= 255); ++ if (numCoefficients < 7 || numCoefficients > 255) ++ { ++ _af_error(AF_BAD_HEADER, ++ "Bad number of coefficients"); ++ return AF_FAIL; ++ } + + m_msadpcmNumCoefficients = numCoefficients; + +@@ -834,6 +840,8 @@ + } + + TrackSetup *track = setup->getTrack(); ++ if (!track) ++ return AF_NULL_FILESETUP; + + if (track->f.isCompressed()) + { +diff -Nur audiofile-0.3.6/sfcommands/sfconvert.c audiofile-0.3.6-pull42/sfcommands/sfconvert.c +--- audiofile-0.3.6/sfcommands/sfconvert.c 2013-03-06 06:30:03.000000000 +0100 ++++ audiofile-0.3.6-pull42/sfcommands/sfconvert.c 2017-03-10 15:40:02.000000000 +0100 +@@ -45,6 +45,33 @@ + void usageerror (void); + bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid); + ++int firstBitSet(int x) ++{ ++ int position=0; ++ while (x!=0) ++ { ++ x>>=1; ++ ++position; ++ } ++ return position; ++} ++ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++bool multiplyCheckOverflow(int a, int b, int *result) ++{ ++#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow)) ++ return __builtin_mul_overflow(a, b, result); ++#else ++ if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits ++ return true; ++ *result = a * b; ++ return false; ++#endif ++} ++ + int main (int argc, char **argv) + { + if (argc == 2) +@@ -323,8 +350,11 @@ + { + int frameSize = afGetVirtualFrameSize(infile, trackid, 1); + +- const int kBufferFrameCount = 65536; +- void *buffer = malloc(kBufferFrameCount * frameSize); ++ int kBufferFrameCount = 65536; ++ int bufferSize; ++ while (multiplyCheckOverflow(kBufferFrameCount, frameSize, &bufferSize)) ++ kBufferFrameCount /= 2; ++ void *buffer = malloc(bufferSize); + + AFframecount totalFrames = afGetFrameCount(infile, AF_DEFAULT_TRACK); + AFframecount totalFramesWritten = 0; diff --git a/audiofile-0.3.6-pull43.patch b/audiofile-0.3.6-pull43.patch new file mode 100644 index 0000000..4ad1152 --- /dev/null +++ b/audiofile-0.3.6-pull43.patch @@ -0,0 +1,21 @@ +diff -Nur audiofile-0.3.6/libaudiofile/modules/IMA.cpp audiofile-0.3.6-pull43/libaudiofile/modules/IMA.cpp +--- audiofile-0.3.6/libaudiofile/modules/IMA.cpp 2013-03-06 06:30:03.000000000 +0100 ++++ audiofile-0.3.6-pull43/libaudiofile/modules/IMA.cpp 2017-03-06 18:06:35.000000000 +0100 +@@ -169,7 +169,7 @@ + if (encoded[1] & 0x80) + m_adpcmState[c].previousValue -= 0x10000; + +- m_adpcmState[c].index = encoded[2]; ++ m_adpcmState[c].index = clamp(encoded[2], 0, 88); + + *decoded++ = m_adpcmState[c].previousValue; + +@@ -210,7 +210,7 @@ + predictor -= 0x10000; + + state.previousValue = clamp(predictor, MIN_INT16, MAX_INT16); +- state.index = encoded[1] & 0x7f; ++ state.index = clamp(encoded[1] & 0x7f, 0, 88); + encoded += 2; + + for (int n=0; nbuffer, m_bytesPerPacket * blockCount); +- int blocksRead = bytesRead >= 0 ? bytesRead / m_bytesPerPacket : 0; ++ int blocksRead = (bytesRead >= 0 && m_bytesPerPacket > 0) ? bytesRead / m_bytesPerPacket : 0; + + // Decompress into m_outChunk. + for (int i=0; if.sampleWidth = 16; diff --git a/audiofile-0.3.6.tar.gz b/audiofile-0.3.6.tar.gz new file mode 100644 index 0000000..a5a5f85 Binary files /dev/null and b/audiofile-0.3.6.tar.gz differ diff --git a/audiofile.spec b/audiofile.spec new file mode 100644 index 0000000..3487586 --- /dev/null +++ b/audiofile.spec @@ -0,0 +1,95 @@ +Name: audiofile +Version: 0.3.6 +Release: 22 +Summary: Library for reading and writing audio files in many common formats +License: LGPLv2+ and GPLv2+ +URL: http://audiofile.68k.org/ +Source0: http://audiofile.68k.org/%{name}-%{version}.tar.gz +Patch0: audiofile-0.3.6-CVE-2015-7747.patch +Patch1: audiofile-0.3.6-left-shift-neg.patch +Patch2: audiofile-0.3.6-narrowing.patch +Patch3: audiofile-0.3.6-pull42.patch +Patch4: audiofile-0.3.6-pull43.patch +Patch5: audiofile-0.3.6-pull44.patch + +BuildRequires: gcc-c++ libtool alsa-lib-devel flac-devel + +%description +The Audio File Library is a C-based library for reading and writing audio files in many +common formats. + +The Audio File Library provides a uniform API which abstracts away details of file formats +and data formats. The same calls for opening a file, accessing and manipulating audio +metadata (e.g. sample rate, sample format, textual information, MIDI parameters), and +reading and writing sample data will work with any supported audio file format. + +%package devel +Summary: Development files for Audio File applications +Requires: %{name}%{?_isa} = %{version}-%{release} +Provides: audiofile-static +Obsoletes: audiofile-static + +%description devel +The audiofile-devel package contains libraries, include files, and +other resources you can use to develop Audio File applications. + +%package_help + +%prep +%autosetup -n %{name}-%{version} -p1 + +%build +%configure +%make_build + +%install +rm -rf $RPM_BUILD_ROOT +%make_install +rm -f $RPM_BUILD_ROOT%{_libdir}/libaudiofile.la + +%check +make check + +%pre + +%preun + +%post + +%postun + +%ldconfig_scriptlets + +%files +%doc ACKNOWLEDGEMENTS AUTHORS NEWS NOTES README TODO COPYING* +%{_bindir}/sfconvert +%{_bindir}/sfinfo +%{_libdir}/lib*.so.1* + +%files devel +%doc ChangeLog docs/*.3.txt +%{_libdir}/libaudiofile.so +%{_libdir}/pkgconfig/audiofile.pc +%{_includedir}/* +%{_libdir}/libaudiofile.a + +%files help +%{_mandir}/man1/* +%{_mandir}/man3/* + +%changelog +* Fri Sep 27 2019 chengquan - 0.3.6-22 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:add help package and merge devel package + +* Tue Sep 17 2019 shenyangyang - 0.3.6-21 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:and % before isa of devel + +* Tue Aug 13 2019 openEuler Buildteam - 0.3.6-20 +- Package init +