Compare commits
10 Commits
ba3c548d39
...
4521d8348b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4521d8348b | ||
|
|
240af49c1f | ||
|
|
50dbf3f65b | ||
|
|
6950d4d40e | ||
|
|
9e85f6378e | ||
|
|
7d2f975107 | ||
|
|
53fbff680e | ||
|
|
e87afbbb83 | ||
|
|
5f3a4dfe39 | ||
|
|
b6466eff57 |
@ -1,12 +0,0 @@
|
||||
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));
|
||||
@ -1,48 +0,0 @@
|
||||
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<Format>::UnsignedType UnsignedType;
|
||||
|
||||
static const int kScaleBits = (Format + 1) * CHAR_BIT - 1;
|
||||
- static const int kMinSignedValue = -1 << kScaleBits;
|
||||
+ static const int kMinSignedValue = 0-(1U<<kScaleBits);
|
||||
|
||||
struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
|
||||
{
|
||||
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;
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
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
|
||||
};
|
||||
@ -1,176 +0,0 @@
|
||||
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<blocksRead; i++)
|
||||
{
|
||||
- decodeBlock(static_cast<const uint8_t *>(m_inChunk->buffer) + i * m_bytesPerPacket,
|
||||
- static_cast<int16_t *>(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount);
|
||||
+ if (decodeBlock(static_cast<const uint8_t *>(m_inChunk->buffer) + i * m_bytesPerPacket,
|
||||
+ static_cast<int16_t *>(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<int16_t>(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;
|
||||
@ -1,21 +0,0 @@
|
||||
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; n<m_framesPerPacket; n+=2)
|
||||
@ -1,31 +0,0 @@
|
||||
diff -Nur audiofile-0.3.6/libaudiofile/modules/BlockCodec.cpp audiofile-0.3.6-pull44/libaudiofile/modules/BlockCodec.cpp
|
||||
--- audiofile-0.3.6/libaudiofile/modules/BlockCodec.cpp 2013-03-06 06:30:03.000000000 +0100
|
||||
+++ audiofile-0.3.6-pull44/libaudiofile/modules/BlockCodec.cpp 2017-03-09 10:21:18.000000000 +0100
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
// Read the compressed data.
|
||||
ssize_t bytesRead = read(m_inChunk->buffer, 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; i<blocksRead; i++)
|
||||
diff -Nur audiofile-0.3.6/libaudiofile/WAVE.cpp audiofile-0.3.6-pull44/libaudiofile/WAVE.cpp
|
||||
--- audiofile-0.3.6/libaudiofile/WAVE.cpp 2013-03-06 06:30:03.000000000 +0100
|
||||
+++ audiofile-0.3.6-pull44/libaudiofile/WAVE.cpp 2017-03-09 10:21:18.000000000 +0100
|
||||
@@ -326,6 +326,7 @@
|
||||
{
|
||||
_af_error(AF_BAD_NOT_IMPLEMENTED,
|
||||
"IMA ADPCM compression supports only 4 bits per sample");
|
||||
+ return AF_FAIL;
|
||||
}
|
||||
|
||||
int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
|
||||
@@ -333,6 +334,7 @@
|
||||
{
|
||||
_af_error(AF_BAD_CODEC_CONFIG,
|
||||
"Invalid samples per block for IMA ADPCM compression");
|
||||
+ return AF_FAIL;
|
||||
}
|
||||
|
||||
track->f.sampleWidth = 16;
|
||||
13
audiofile-CVE-2015-7747.patch
Normal file
13
audiofile-CVE-2015-7747.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/libaudiofile/modules/ModuleState.cpp b/libaudiofile/modules/ModuleState.cpp
|
||||
index f76c495..0c29d7a 100644
|
||||
--- a/libaudiofile/modules/ModuleState.cpp
|
||||
+++ b/libaudiofile/modules/ModuleState.cpp
|
||||
@@ -402,7 +402,7 @@ status ModuleState::arrange(AFfilehandle file, Track *track)
|
||||
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));
|
||||
53
audiofile-fix-gcc6-compile-error.patch
Normal file
53
audiofile-fix-gcc6-compile-error.patch
Normal file
@ -0,0 +1,53 @@
|
||||
diff --git a/libaudiofile/modules/SimpleModule.h b/libaudiofile/modules/SimpleModule.h
|
||||
index 03c6c69..8e453a7 100644
|
||||
--- a/libaudiofile/modules/SimpleModule.h
|
||||
+++ b/libaudiofile/modules/SimpleModule.h
|
||||
@@ -123,7 +123,7 @@ struct signConverter
|
||||
typedef typename IntTypes<Format>::UnsignedType UnsignedType;
|
||||
|
||||
static const int kScaleBits = (Format + 1) * CHAR_BIT - 1;
|
||||
- static const int kMinSignedValue = -1 << kScaleBits;
|
||||
+ static const int kMinSignedValue = -1U << kScaleBits;
|
||||
|
||||
struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
|
||||
{
|
||||
diff --git a/test/FloatToInt.cpp b/test/FloatToInt.cpp
|
||||
index 0d179a8..624be25 100644
|
||||
--- a/test/FloatToInt.cpp
|
||||
+++ b/test/FloatToInt.cpp
|
||||
@@ -115,7 +115,7 @@ TEST_F(FloatToIntTest, Int16)
|
||||
EXPECT_EQ(readData[i], expectedData[i]);
|
||||
}
|
||||
|
||||
-static const int32_t kMinInt24 = -1<<23;
|
||||
+static const int32_t kMinInt24 = -1U<<23;
|
||||
static const int32_t kMaxInt24 = (1<<23) - 1;
|
||||
|
||||
TEST_F(FloatToIntTest, Int24)
|
||||
diff --git a/test/IntToFloat.cpp b/test/IntToFloat.cpp
|
||||
index b716635..b619a2c 100644
|
||||
--- a/test/IntToFloat.cpp
|
||||
+++ b/test/IntToFloat.cpp
|
||||
@@ -117,7 +117,7 @@ TEST_F(IntToFloatTest, Int16)
|
||||
EXPECT_EQ(readData[i], expectedData[i]);
|
||||
}
|
||||
|
||||
-static const int32_t kMinInt24 = -1<<23;
|
||||
+static const int32_t kMinInt24 = -1U<<23;
|
||||
static const int32_t kMaxInt24 = (1<<23) - 1;
|
||||
|
||||
TEST_F(IntToFloatTest, Int24)
|
||||
diff --git a/test/Sign.cpp b/test/Sign.cpp
|
||||
index 7275399..b3609ca 100644
|
||||
--- a/test/Sign.cpp
|
||||
+++ b/test/Sign.cpp
|
||||
@@ -116,7 +116,7 @@ TEST_F(SignConversionTest, Int16)
|
||||
EXPECT_EQ(readData[i], expectedData[i]);
|
||||
}
|
||||
|
||||
-static const int32_t kMinInt24 = -1<<23;
|
||||
+static const int32_t kMinInt24 = -1U<<23;
|
||||
static const int32_t kMaxInt24 = (1<<23) - 1;
|
||||
static const uint32_t kMaxUInt24 = (1<<24) - 1;
|
||||
|
||||
|
||||
47
audiofile-fix-test-compile-err.patch
Normal file
47
audiofile-fix-test-compile-err.patch
Normal file
@ -0,0 +1,47 @@
|
||||
From ea3b8e88065b9698357b3636363b78c2bb74e240 Mon Sep 17 00:00:00 2001
|
||||
From: Shouping Wang<wangshouping@huawei.com>
|
||||
Date: Sat, 21 Mar 2020 18:54:32 +0800
|
||||
Subject: [PATCH] audiofile-fix-test-compile-err
|
||||
|
||||
Signed-off-by: Shouping Wang<wangshouping@huawei.com>
|
||||
---
|
||||
test/NeXT.cpp | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/test/NeXT.cpp b/test/NeXT.cpp
|
||||
index 7e39850..b8829a9 100644
|
||||
--- a/test/NeXT.cpp
|
||||
+++ b/test/NeXT.cpp
|
||||
@@ -41,9 +41,9 @@ const char kDataUnspecifiedLength[] =
|
||||
{
|
||||
'.', 's', 'n', 'd',
|
||||
0, 0, 0, 24, // offset of 24 bytes
|
||||
- 0xff, 0xff, 0xff, 0xff, // unspecified length
|
||||
+ (char)0xff, (char)0xff, (char)0xff, (char)0xff, // unspecified length
|
||||
0, 0, 0, 3, // 16-bit linear
|
||||
- 0, 0, 172, 68, // 44100 Hz
|
||||
+ 0, 0, (char)172, 68, // 44100 Hz
|
||||
0, 0, 0, 1, // 1 channel
|
||||
0, 1,
|
||||
0, 1,
|
||||
@@ -63,7 +63,7 @@ const char kDataTruncated[] =
|
||||
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, (char)172, 68, // 44100 Hz
|
||||
0, 0, 0, 1, // 1 channel
|
||||
0, 1,
|
||||
0, 1,
|
||||
@@ -158,7 +158,7 @@ const char kDataZeroChannels[] =
|
||||
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, (char)172, 68, // 44100 Hz
|
||||
0, 0, 0, 0, // 0 channels
|
||||
0, 1
|
||||
};
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
Name: audiofile
|
||||
Version: 0.3.6
|
||||
Release: 22
|
||||
Release: 27
|
||||
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
|
||||
Patch0: audiofile-CVE-2015-7747.patch
|
||||
Patch1: audiofile-fix-gcc6-compile-error.patch
|
||||
Patch2: audiofile-fix-test-compile-err.patch
|
||||
Patch3: backport-CVE-2017-6828.patch
|
||||
Patch4: backport-CVE-2017-6829.patch
|
||||
Patch5: backport-CVE-2017-6831.patch
|
||||
Patch6: backport-CVE-2017-6838.patch
|
||||
Patch7: backport-CVE-2017-6839.patch
|
||||
|
||||
BuildRequires: gcc-c++ libtool alsa-lib-devel flac-devel
|
||||
BuildRequires: gcc-c++ libtool alsa-lib-devel flac-devel chrpath
|
||||
|
||||
%description
|
||||
The Audio File Library is a C-based library for reading and writing audio files in many
|
||||
@ -46,6 +48,8 @@ other resources you can use to develop Audio File applications.
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
%make_install
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/libaudiofile.la
|
||||
chrpath --delete %{buildroot}%{_bindir}/sfinfo
|
||||
chrpath --delete %{buildroot}%{_bindir}/sfconvert
|
||||
|
||||
%check
|
||||
make check
|
||||
@ -78,6 +82,33 @@ make check
|
||||
%{_mandir}/man3/*
|
||||
|
||||
%changelog
|
||||
* Mon Sep 6 2021 Hongxun Ren<renhongxun@huawei.com> - 0.3.6-27
|
||||
- Type:enhanence
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:remove rpath
|
||||
|
||||
* Thu Jul 22 2021 wuchaochao <wuchaochao4@huawei.com> - 0.3.6-26
|
||||
- Remove BuildRequires gdb
|
||||
|
||||
* Fri Feb 19 2021 shixuantong<shixuantong@huawei.com> - 0.3.6-25
|
||||
- Type:cves
|
||||
- ID:CVE-2017-6828 CVE-2017-6829 CVE-2017-6831 CVE-2017-6838 CVE-2017-6839
|
||||
- SUG:NA
|
||||
- DESC:fix CVE-2017-6828 CVE-2017-6829 CVE-2017-6831 CVE-2017-6838 CVE-2017-6839
|
||||
|
||||
* Sat Mar 21 2020 Shouping Wang<wangshouping@huawei.com> - 0.3.6-24
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:fix test compile err
|
||||
|
||||
* Thu Jan 9 2020 JeanLeo<liujianliu.liu@huawei.com> - 0.3.6-23
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:update software package
|
||||
|
||||
* Fri Sep 27 2019 chengquan<chengquan3@huawei.com> - 0.3.6-22
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
31
backport-CVE-2017-6828.patch
Normal file
31
backport-CVE-2017-6828.patch
Normal file
@ -0,0 +1,31 @@
|
||||
From c48e4c6503f7dabd41f11d4c9c7b7f8960e7f2c0 Mon Sep 17 00:00:00 2001
|
||||
From: Antonio Larrosa <larrosa@kde.org>
|
||||
Date: Mon, 6 Mar 2017 12:51:22 +0100
|
||||
Subject: [PATCH] Always check the number of coefficients
|
||||
|
||||
When 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
|
||||
---
|
||||
libaudiofile/WAVE.cpp | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/libaudiofile/WAVE.cpp b/libaudiofile/WAVE.cpp
|
||||
index 0e81cf7..61f9541 100644
|
||||
--- a/libaudiofile/WAVE.cpp
|
||||
+++ b/libaudiofile/WAVE.cpp
|
||||
@@ -281,6 +281,12 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
|
||||
|
||||
/* 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;
|
||||
|
||||
34
backport-CVE-2017-6829.patch
Normal file
34
backport-CVE-2017-6829.patch
Normal file
@ -0,0 +1,34 @@
|
||||
From 25eb00ce913452c2e614548d7df93070bf0d066f Mon Sep 17 00:00:00 2001
|
||||
From: Antonio Larrosa <larrosa@kde.org>
|
||||
Date: Mon, 6 Mar 2017 18:02:31 +0100
|
||||
Subject: [PATCH] clamp index values to fix index overflow in IMA.cpp
|
||||
|
||||
This 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/)
|
||||
---
|
||||
libaudiofile/modules/IMA.cpp | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libaudiofile/modules/IMA.cpp b/libaudiofile/modules/IMA.cpp
|
||||
index 7476d44..df4aad6 100644
|
||||
--- a/libaudiofile/modules/IMA.cpp
|
||||
+++ b/libaudiofile/modules/IMA.cpp
|
||||
@@ -169,7 +169,7 @@ int IMA::decodeBlockWAVE(const uint8_t *encoded, int16_t *decoded)
|
||||
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 @@ int IMA::decodeBlockQT(const uint8_t *encoded, int16_t *decoded)
|
||||
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; n<m_framesPerPacket; n+=2)
|
||||
37
backport-CVE-2017-6831.patch
Normal file
37
backport-CVE-2017-6831.patch
Normal file
@ -0,0 +1,37 @@
|
||||
From a2e9eab8ea87c4ffc494d839ebb4ea145eb9f2e6 Mon Sep 17 00:00:00 2001
|
||||
From: Antonio Larrosa <larrosa@kde.org>
|
||||
Date: Mon, 6 Mar 2017 18:59:26 +0100
|
||||
Subject: [PATCH] Actually fail when error occurs in parseFormat
|
||||
|
||||
When 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/
|
||||
)
|
||||
---
|
||||
libaudiofile/WAVE.cpp | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/libaudiofile/WAVE.cpp b/libaudiofile/WAVE.cpp
|
||||
index 0e81cf7..d762249 100644
|
||||
--- a/libaudiofile/WAVE.cpp
|
||||
+++ b/libaudiofile/WAVE.cpp
|
||||
@@ -326,6 +326,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
|
||||
{
|
||||
_af_error(AF_BAD_NOT_IMPLEMENTED,
|
||||
"IMA ADPCM compression supports only 4 bits per sample");
|
||||
+ return AF_FAIL;
|
||||
}
|
||||
|
||||
int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
|
||||
@@ -333,6 +334,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
|
||||
{
|
||||
_af_error(AF_BAD_CODEC_CONFIG,
|
||||
"Invalid samples per block for IMA ADPCM compression");
|
||||
+ return AF_FAIL;
|
||||
}
|
||||
|
||||
track->f.sampleWidth = 16;
|
||||
67
backport-CVE-2017-6838.patch
Normal file
67
backport-CVE-2017-6838.patch
Normal file
@ -0,0 +1,67 @@
|
||||
From 7d65f89defb092b63bcbc5d98349fb222ca73b3c Mon Sep 17 00:00:00 2001
|
||||
From: Antonio Larrosa <larrosa@kde.org>
|
||||
Date: Mon, 6 Mar 2017 13:54:52 +0100
|
||||
Subject: [PATCH] Check for multiplication overflow in sfconvert
|
||||
|
||||
Checks 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
|
||||
---
|
||||
sfcommands/sfconvert.c | 34 ++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 32 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/sfcommands/sfconvert.c b/sfcommands/sfconvert.c
|
||||
index 80a1bc4..970a3e4 100644
|
||||
--- a/sfcommands/sfconvert.c
|
||||
+++ b/sfcommands/sfconvert.c
|
||||
@@ -45,6 +45,33 @@ void printusage (void);
|
||||
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
|
||||
+
|
||||
+int 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 @@ bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid)
|
||||
{
|
||||
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;
|
||||
117
backport-CVE-2017-6839.patch
Normal file
117
backport-CVE-2017-6839.patch
Normal file
@ -0,0 +1,117 @@
|
||||
From beacc44eb8cdf6d58717ec1a5103c5141f1b37f9 Mon Sep 17 00:00:00 2001
|
||||
From: Antonio Larrosa <larrosa@kde.org>
|
||||
Date: Mon, 6 Mar 2017 13:43:53 +0100
|
||||
Subject: [PATCH] Check for multiplication overflow in MSADPCM decodeSample
|
||||
|
||||
Check 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
|
||||
---
|
||||
libaudiofile/modules/BlockCodec.cpp | 5 +--
|
||||
libaudiofile/modules/MSADPCM.cpp | 47 ++++++++++++++++++++++++++---
|
||||
2 files changed, 46 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/libaudiofile/modules/BlockCodec.cpp b/libaudiofile/modules/BlockCodec.cpp
|
||||
index 45925e8..4731be1 100644
|
||||
--- a/libaudiofile/modules/BlockCodec.cpp
|
||||
+++ b/libaudiofile/modules/BlockCodec.cpp
|
||||
@@ -52,8 +52,9 @@ void BlockCodec::runPull()
|
||||
// Decompress into m_outChunk.
|
||||
for (int i=0; i<blocksRead; i++)
|
||||
{
|
||||
- decodeBlock(static_cast<const uint8_t *>(m_inChunk->buffer) + i * m_bytesPerPacket,
|
||||
- static_cast<int16_t *>(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount);
|
||||
+ if (decodeBlock(static_cast<const uint8_t *>(m_inChunk->buffer) + i * m_bytesPerPacket,
|
||||
+ static_cast<int16_t *>(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount)==0)
|
||||
+ break;
|
||||
|
||||
framesRead += m_framesPerPacket;
|
||||
}
|
||||
diff --git a/libaudiofile/modules/MSADPCM.cpp b/libaudiofile/modules/MSADPCM.cpp
|
||||
index 8ea3c85..ef9c38c 100644
|
||||
--- a/libaudiofile/modules/MSADPCM.cpp
|
||||
+++ b/libaudiofile/modules/MSADPCM.cpp
|
||||
@@ -101,24 +101,60 @@ static const int16_t adaptationTable[] =
|
||||
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
|
||||
+
|
||||
+int 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<int16_t>(linearSample);
|
||||
}
|
||||
@@ -212,13 +248,16 @@ int MSADPCM::decodeBlock(const uint8_t *encoded, int16_t *decoded)
|
||||
{
|
||||
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++;
|
||||
Loading…
x
Reference in New Issue
Block a user