Blame SOURCES/wavpack-5.4.0-CVE-2021-44269-heap-Out-of-bounds-Read.patch

f81b67
diff --git a/cli/dsdiff.c b/cli/dsdiff.c
f81b67
index d7adb6a..5bdcae3 100644
f81b67
--- a/cli/dsdiff.c
f81b67
+++ b/cli/dsdiff.c
f81b67
@@ -278,6 +278,12 @@ int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, Wavpa
f81b67
             }
f81b67
 
f81b67
             total_samples = dff_chunk_header.ckDataSize / config->num_channels;
f81b67
+
f81b67
+            if (total_samples <= 0 || total_samples > MAX_WAVPACK_SAMPLES) {
f81b67
+                error_line ("%s is not a valid .DFF file!", infilename);
f81b67
+                return WAVPACK_SOFT_ERROR;
f81b67
+            }
f81b67
+
f81b67
             break;
f81b67
         }
f81b67
         else {          // just copy unknown chunks to output file
f81b67
diff --git a/cli/dsf.c b/cli/dsf.c
f81b67
index e1d7973..dddd488 100644
f81b67
--- a/cli/dsf.c
f81b67
+++ b/cli/dsf.c
f81b67
@@ -113,6 +113,7 @@ int ParseDsfHeaderConfig (FILE *infile, char *infilename, char *fourcc, WavpackC
f81b67
 
f81b67
     if (format_chunk.ckSize != sizeof (DSFFormatChunk) || format_chunk.formatVersion != 1 ||
f81b67
         format_chunk.formatID != 0 || format_chunk.blockSize != DSF_BLOCKSIZE || format_chunk.reserved ||
f81b67
+        format_chunk.sampleCount <= 0 || format_chunk.sampleCount > MAX_WAVPACK_SAMPLES * 8 ||
f81b67
         (format_chunk.bitsPerSample != 1 && format_chunk.bitsPerSample != 8) ||
f81b67
         format_chunk.numChannels < 1 || format_chunk.numChannels > 6 ||
f81b67
         format_chunk.chanType < 1 || format_chunk.chanType > NUM_CHAN_TYPES) {
f81b67