blob: c80af44b37c3ad6ffb9269de60628912859fa515 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
--- libmodplug/src/sndfile.cpp 2006/08/10 02:26:44 1.3
+++ libmodplug/src/sndfile.cpp 2006/11/02 04:19:00 1.4
@@ -5,7 +5,7 @@
* Adam Goode <adam@evdebs.org> (endian and char fixes for PPC)
*/
-#include <math.h> //for GCCFIX
+#include <math.h> //for GCCFIX
#include <libmodplug/stdafx.h>
#include <libmodplug/sndfile.h>
@@ -228,7 +228,8 @@
if (pins->nGlobalVol > 64) pins->nGlobalVol = 64;
}
// Check invalid instruments
- while ((m_nInstruments > 0) && (!Headers[m_nInstruments])) m_nInstruments--;
+ while ((m_nInstruments > 0) && (!Headers[m_nInstruments]))
+ m_nInstruments--;
// Set default values
if (m_nSongPreAmp < 0x20) m_nSongPreAmp = 0x20;
if (m_nDefaultTempo < 32) m_nDefaultTempo = 125;
@@ -1081,11 +1082,12 @@
UINT CSoundFile::ReadSample(MODINSTRUMENT *pIns, UINT nFlags, LPCSTR lpMemFile, DWORD dwMemLength)
-//------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
{
UINT len = 0, mem = pIns->nLength+6;
- if ((!pIns) || (pIns->nLength < 4) || (!lpMemFile)) return 0;
+ // Disable >2Gb samples,(preventing buffer overflow in AllocateSample)
+ if ((!pIns) || ((int)pIns->nLength < 4) || (!lpMemFile)) return 0;
if (pIns->nLength > MAX_SAMPLE_LENGTH) pIns->nLength = MAX_SAMPLE_LENGTH;
pIns->uFlags &= ~(CHN_16BIT|CHN_STEREO);
if (nFlags & RSF_16BIT)
|