59 lines
2.1 KiB
Diff
59 lines
2.1 KiB
Diff
From e0240689056e4182fffdc2a16aa6e3425a15e275 Mon Sep 17 00:00:00 2001
|
|
From: oparviainen <oparviai@iki.fi>
|
|
Date: Mon, 13 Aug 2018 19:16:16 +0300
|
|
Subject: [PATCH 3/4] Fixed WavFile header/fact not-too-small check
|
|
|
|
---
|
|
source/SoundStretch/WavFile.cpp | 22 +++++++++++-----------
|
|
1 file changed, 11 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/source/SoundStretch/WavFile.cpp b/source/SoundStretch/WavFile.cpp
|
|
index 4af7a4c..3421bca 100644
|
|
--- a/source/SoundStretch/WavFile.cpp
|
|
+++ b/source/SoundStretch/WavFile.cpp
|
|
@@ -518,13 +518,13 @@ int WavInFile::readHeaderBlock()
|
|
// swap byte order if necessary
|
|
_swap32(nLen);
|
|
|
|
- // verify that header length isn't smaller than expected
|
|
- if (nLen < sizeof(header.format) - 8) return -1;
|
|
+ // calculate how much length differs from expected
|
|
+ nDump = nLen - ((int)sizeof(header.format) - 8);
|
|
|
|
- header.format.format_len = nLen;
|
|
+ // verify that header length isn't smaller than expected structure
|
|
+ if (nDump < 0) return -1;
|
|
|
|
- // calculate how much length differs from expected
|
|
- nDump = nLen - ((int)sizeof(header.format) - 8);
|
|
+ header.format.format_len = nLen;
|
|
|
|
// if format_len is larger than expected, read only as much data as we've space for
|
|
if (nDump > 0)
|
|
@@ -561,16 +561,16 @@ int WavInFile::readHeaderBlock()
|
|
// read length of the fact field
|
|
if (fread(&nLen, sizeof(int), 1, fptr) != 1) return -1;
|
|
// swap byte order if necessary
|
|
- _swap32(nLen); // int fact_len;
|
|
-
|
|
- // verify that fact length isn't smaller than expected
|
|
- if (nLen < sizeof(header.fact) - 8) return -1;
|
|
-
|
|
- header.fact.fact_len = nLen;
|
|
+ _swap32(nLen);
|
|
|
|
// calculate how much length differs from expected
|
|
nDump = nLen - ((int)sizeof(header.fact) - 8);
|
|
|
|
+ // verify that fact length isn't smaller than expected structure
|
|
+ if (nDump < 0) return -1;
|
|
+
|
|
+ header.fact.fact_len = nLen;
|
|
+
|
|
// if format_len is larger than expected, read only as much data as we've space for
|
|
if (nDump > 0)
|
|
{
|
|
--
|
|
2.18.0
|
|
|