WavPack: fix for CVE-2019-11498

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
This commit is contained in:
Peter Lemenkov 2019-05-17 13:26:28 +03:00
parent abbd04c47f
commit b69b5ea9d2
5 changed files with 128 additions and 1 deletions

View File

@ -0,0 +1,18 @@
From: David Bryant <david@wavpack.com>
Date: Sun, 26 Aug 2018 20:24:00 -0700
Subject: [PATCH] issue #41: make sure DFF chunk does not have negative length
diff --git a/cli/dsdiff.c b/cli/dsdiff.c
index fa56bbb..c65aed3 100644
--- a/cli/dsdiff.c
+++ b/cli/dsdiff.c
@@ -188,7 +188,7 @@ int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, Wavpa
cptr += sizeof (dff_chunk_header);
WavpackBigEndianToNative (&dff_chunk_header, DFFChunkHeaderFormat);
- if (eptr - cptr >= dff_chunk_header.ckDataSize) {
+ if (dff_chunk_header.ckDataSize > 0 && dff_chunk_header.ckDataSize <= eptr - cptr) {
if (!strncmp (dff_chunk_header.ckID, "FS ", 4) && dff_chunk_header.ckDataSize == 4) {
memcpy (&sampleRate, cptr, sizeof (sampleRate));
WavpackBigEndianToNative (&sampleRate, "L");

View File

@ -0,0 +1,34 @@
From: David Bryant <david@wavpack.com>
Date: Sun, 26 Aug 2018 21:25:38 -0700
Subject: [PATCH] issue #43: catch zero channel count in DSF and DSDIFF files
diff --git a/cli/dsdiff.c b/cli/dsdiff.c
index c65aed3..738a46b 100644
--- a/cli/dsdiff.c
+++ b/cli/dsdiff.c
@@ -204,6 +204,12 @@ int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, Wavpa
chansSpecified = (int)(dff_chunk_header.ckDataSize - sizeof (numChannels)) / 4;
+ if (numChannels < chansSpecified || numChannels < 1) {
+ error_line ("%s is not a valid .DFF file!", infilename);
+ free (prop_chunk);
+ return WAVPACK_SOFT_ERROR;
+ }
+
while (chansSpecified--) {
if (!strncmp (cptr, "SLFT", 4) || !strncmp (cptr, "MLFT", 4))
chanMask |= 0x1;
diff --git a/cli/dsf.c b/cli/dsf.c
index cd82ae9..d12e409 100644
--- a/cli/dsf.c
+++ b/cli/dsf.c
@@ -122,6 +122,7 @@ int ParseDsfHeaderConfig (FILE *infile, char *infilename, char *fourcc, WavpackC
if (format_chunk.ckSize != sizeof (DSFFormatChunk) || format_chunk.formatVersion != 1 ||
format_chunk.formatID != 0 || format_chunk.blockSize != DSF_BLOCKSIZE || format_chunk.reserved ||
(format_chunk.bitsPerSample != 1 && format_chunk.bitsPerSample != 8) ||
+ format_chunk.numChannels < 1 || format_chunk.numChannels > 6 ||
format_chunk.chanType < 1 || format_chunk.chanType > NUM_CHAN_TYPES) {
error_line ("%s is not a valid .DSF file!", infilename);
return WAVPACK_SOFT_ERROR;

View File

@ -0,0 +1,40 @@
From: David Bryant <david@wavpack.com>
Date: Sat, 2 Mar 2019 18:37:14 -0800
Subject: [PATCH] issue #65: make sure DSDIFF files have a valid channel count
diff --git a/cli/dsdiff.c b/cli/dsdiff.c
index 738a46b..1d637d7 100644
--- a/cli/dsdiff.c
+++ b/cli/dsdiff.c
@@ -180,7 +180,7 @@ int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, Wavpa
if (!strncmp (prop_chunk, "SND ", 4)) {
char *cptr = prop_chunk + 4, *eptr = prop_chunk + dff_chunk_header.ckDataSize;
- uint16_t numChannels, chansSpecified, chanMask = 0;
+ uint16_t numChannels = 0, chansSpecified, chanMask = 0;
uint32_t sampleRate;
while (eptr - cptr >= sizeof (dff_chunk_header)) {
@@ -204,7 +204,7 @@ int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, Wavpa
chansSpecified = (int)(dff_chunk_header.ckDataSize - sizeof (numChannels)) / 4;
- if (numChannels < chansSpecified || numChannels < 1) {
+ if (numChannels < chansSpecified || numChannels < 1 || numChannels > 256) {
error_line ("%s is not a valid .DFF file!", infilename);
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
@@ -279,6 +279,12 @@ int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, Wavpa
free (prop_chunk);
}
else if (!strncmp (dff_chunk_header.ckID, "DSD ", 4)) {
+
+ if (!config->num_channels) {
+ error_line ("%s is not a valid .DFF file!", infilename);
+ return WAVPACK_SOFT_ERROR;
+ }
+
total_samples = dff_chunk_header.ckDataSize / config->num_channels;
break;
}

View File

@ -0,0 +1,28 @@
From: David Bryant <david@wavpack.com>
Date: Tue, 5 Mar 2019 21:32:27 -0800
Subject: [PATCH] issue #67: make sure sample rate is specified and non-zero in
DFF files
diff --git a/cli/dsdiff.c b/cli/dsdiff.c
index 1d637d7..32d276c 100644
--- a/cli/dsdiff.c
+++ b/cli/dsdiff.c
@@ -181,7 +181,7 @@ int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, Wavpa
if (!strncmp (prop_chunk, "SND ", 4)) {
char *cptr = prop_chunk + 4, *eptr = prop_chunk + dff_chunk_header.ckDataSize;
uint16_t numChannels = 0, chansSpecified, chanMask = 0;
- uint32_t sampleRate;
+ uint32_t sampleRate = 0;
while (eptr - cptr >= sizeof (dff_chunk_header)) {
memcpy (&dff_chunk_header, cptr, sizeof (dff_chunk_header));
@@ -280,7 +280,7 @@ int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, Wavpa
}
else if (!strncmp (dff_chunk_header.ckID, "DSD ", 4)) {
- if (!config->num_channels) {
+ if (!config->num_channels || !config->sample_rate) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}

View File

@ -1,7 +1,7 @@
Name: wavpack
Summary: A completely open audiocodec
Version: 5.1.0
Release: 12%{?dist}
Release: 13%{?dist}
License: BSD
Url: http://www.wavpack.com/
Source: http://www.wavpack.com/%{name}-%{version}.tar.bz2
@ -12,6 +12,10 @@ Patch4: wavpack-0004-issue-33-sanitize-size-of-unknown-chunks-before-mall.patch
Patch5: wavpack-0005-issue-30-issue-31-issue-32-no-multiple-format-chunks.patch
Patch6: wavpack-0006-issue-53-error-out-on-zero-sample-rate.patch
Patch7: wavpack-0007-issue-54-fix-potential-out-of-bounds-heap-read.patch
Patch8: wavpack-0008-issue-41-make-sure-DFF-chunk-does-not-have-negative-.patch
Patch9: wavpack-0009-issue-43-catch-zero-channel-count-in-DSF-and-DSDIFF-.patch
Patch10: wavpack-0010-issue-65-make-sure-DSDIFF-files-have-a-valid-channel.patch
Patch11: wavpack-0011-issue-67-make-sure-sample-rate-is-specified-and-non-.patch
# For autoreconf
BuildRequires: autoconf
BuildRequires: automake
@ -72,6 +76,9 @@ rm -f %{buildroot}/%{_libdir}/*.la
%doc ChangeLog README
%changelog
* Fri May 17 2019 Peter Lemenkov <lemenkov@gmail.com> - 5.1.0-13
- Fix for CVE-2019-11498
* Wed Apr 10 2019 Peter Lemenkov <lemenkov@gmail.com> - 5.1.0-12
- Fix for CVE-2018-19840, CVE-2018-19841