|
From: <sag...@us...> - 2010-04-07 17:23:38
|
Revision: 566
http://modplug.svn.sourceforge.net/modplug/?rev=566&view=rev
Author: saga-games
Date: 2010-04-07 17:23:25 +0000 (Wed, 07 Apr 2010)
Log Message:
-----------
[Reg] Cannot create S3M files with more than 100 patterns anymore, because...
[Fix] ... it was possible to create S3M files where the 256 parapointers were not enough. It was possible to crash MPT with 669 files with SCRM at position 0x2C because MPT would allow more than 256 parapointer table entries, although it only reserved 256*2 bytes for it.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_s3m.cpp
trunk/OpenMPT/soundlib/mod_specifications.h
Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-04-07 15:19:36 UTC (rev 565)
+++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-04-07 17:23:25 UTC (rev 566)
@@ -270,7 +270,7 @@
dwMemPos = 0x60;
m_nType = MOD_TYPE_S3M;
- memset(m_szNames,0,sizeof(m_szNames));
+ memset(m_szNames, 0, sizeof(m_szNames));
memcpy(m_szNames[0], psfh.name, 28);
SpaceToNullStringFixed(m_szNames[0], 28);
// Speed
@@ -326,12 +326,18 @@
patnum = npat = psfh.patnum;
if (patnum > MAX_PATTERNS) patnum = MAX_PATTERNS;
memset(ptr, 0, sizeof(ptr));
- if (nins+npat)
+
+ // this seems to be corrupted, the table can't really hold that many values.
+ if(nins + npat > 256)
+ return false;
+
+ if (nins + npat)
{
- memcpy(ptr, lpStream+dwMemPos, 2*(nins+npat));
- dwMemPos += 2*(nins+npat);
- const UINT nLoopEnd = min(256, nins+npat);
- for (UINT j = 0; j < nLoopEnd; ++j) {
+ memcpy(ptr, lpStream + dwMemPos, 2 * (nins + npat));
+ dwMemPos += 2 * (nins + npat);
+ const UINT nLoopEnd = min(256, nins + npat);
+ for(UINT j = 0; j < nLoopEnd; ++j)
+ {
ptr[j] = LittleEndianW(ptr[j]);
}
if (psfh.panning_present == 252)
Modified: trunk/OpenMPT/soundlib/mod_specifications.h
===================================================================
--- trunk/OpenMPT/soundlib/mod_specifications.h 2010-04-07 15:19:36 UTC (rev 565)
+++ trunk/OpenMPT/soundlib/mod_specifications.h 2010-04-07 17:23:25 UTC (rev 566)
@@ -295,7 +295,7 @@
true, //Has notecut.
false, //No noteoff.
false, //No notefade.
- 240, //Pattern max.
+ 99, //Pattern max.
255, //Order max.
1, //Channel min
32, //Channel max
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|