[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.438,2.439 script_v100he.cpp,2.122,2.123 script_v72he.cpp,2.253,2.254 script_v80he.cpp,2.91,2.92 script_v90he.cpp,2.224,2.225 scumm.cpp,1.428,1.429 scumm.h,1.576,1.577
kirben
kirben at users.sourceforge.net
Wed Apr 13 03:35:52 CEST 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30080/scumm
Modified Files:
intern.h script_v100he.cpp script_v72he.cpp script_v80he.cpp
script_v90he.cpp scumm.cpp scumm.h
Log Message:
_stringBuffer can have mutple strings, ie in pajama2 startup.
Add safety check for buffer size.
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.438
retrieving revision 2.439
diff -u -d -r2.438 -r2.439
--- intern.h 12 Apr 2005 02:35:58 -0000 2.438
+++ intern.h 13 Apr 2005 10:34:34 -0000 2.439
@@ -752,11 +752,17 @@
#endif
const OpcodeEntryV72he *_opcodesV72he;
+
+ int _stringLength, _stringStart;
+ byte _stringBuffer[4096];
+
WizParameters _wizParams;
public:
ScummEngine_v72he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v70he(detector, syst, gs, md5sum) {}
+ virtual void scummInit();
+
protected:
virtual void setupOpcodes();
virtual void executeOpcode(byte i);
@@ -796,7 +802,7 @@
virtual void decodeParseString(int a, int b);
void decodeScriptString(byte *dst, bool scriptString = false);
- void copyScriptString(byte *dst);
+ void copyScriptString(byte *dst, int dstSize);
byte *heFindResourceData(uint32 tag, byte *ptr);
byte *heFindResource(uint32 tag, byte *ptr);
Index: script_v100he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v100he.cpp,v
retrieving revision 2.122
retrieving revision 2.123
diff -u -d -r2.122 -r2.123
--- script_v100he.cpp 12 Apr 2005 02:35:59 -0000 2.122
+++ script_v100he.cpp 13 Apr 2005 10:34:34 -0000 2.123
@@ -446,7 +446,7 @@
debug(1,"o100_actorOps: case 32 (%d)", i);
break;
case 52: // SO_ACTOR_NAME
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
loadPtrToResource(rtActorName, a->_number, string);
break;
case 53: // SO_ACTOR_NEW
@@ -483,7 +483,7 @@
break;
case 78:
{
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
int slot = pop();
int len = resStrLen(string) + 1;
@@ -596,7 +596,7 @@
memcpy(ah->data, string, len);
break;
case 77: // SO_ASSIGN_STRING
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
len = resStrLen(string) + 1;
ah = defineArray(array, kStringArray, 0, 0, 0, len);
memcpy(ah->data, string, len);
@@ -979,7 +979,7 @@
spriteGroupSet_inc_tx_ty(_curSpriteGroupId, value1, value2);
break;
case 52:
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
break;
case 53:
if (!_curSpriteGroupId)
@@ -1200,7 +1200,7 @@
case 47:
_wizParams.processFlags |= kWPFUseFile;
_wizParams.processMode = 3;
- copyScriptString(_wizParams.filename);
+ copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
break;
case 53:
_wizParams.processMode = 8;
@@ -1235,7 +1235,7 @@
case 64:
_wizParams.processFlags |= kWPFUseFile;
_wizParams.processMode = 4;
- copyScriptString(_wizParams.filename);
+ copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
_wizParams.fileWriteMode = pop();
break;
case 65:
@@ -1272,7 +1272,7 @@
pop();
pop();
pop();
- copyScriptString(filename);
+ copyScriptString(filename, sizeof(filename));
_wizParams.processMode = 15;
break;
case 129:
@@ -1282,7 +1282,7 @@
_wizParams.processMode = 16;
pop();
pop();
- copyScriptString(filename);
+ copyScriptString(filename, sizeof(filename));
break;
case 131:
_wizParams.processMode = 13;
@@ -1589,7 +1589,7 @@
break;
case 137:
- copyScriptString(filename);
+ copyScriptString(filename, sizeof(filename));
_saveLoadFlag = pop();
_saveLoadSlot = 1;
_saveTemporaryState = true;
@@ -1833,7 +1833,7 @@
spriteInfoSet_Inc_tx_ty(spriteId, args[0], args[1]);
break;
case 52:
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
break;
case 53:
if (_curSpriteId > _curMaxSpriteId)
Index: script_v72he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v72he.cpp,v
retrieving revision 2.253
retrieving revision 2.254
diff -u -d -r2.253 -r2.254
--- script_v72he.cpp 13 Apr 2005 06:53:38 -0000 2.253
+++ script_v72he.cpp 13 Apr 2005 10:34:34 -0000 2.254
@@ -518,20 +518,39 @@
}
}
-void ScummEngine_v72he::copyScriptString(byte *dst) {
- int i = 0;
- byte b;
+void ScummEngine_v72he::copyScriptString(byte *dst, int dstSize) {
+ byte string[256];
+ byte chr;
+ int pos = 0;
int array = pop();
if (array == -1) {
- int len = resStrLen(_stringBuffer) + 1;
+ if (_stringLength == 1)
+ error("String stack underflow");
+
+ _stringLength -= 2;
+ while ((chr = _stringBuffer[_stringLength]) != 0) {
+ string[pos] = chr;
+ pos++;
+
+ if (pos > dstSize)
+ error("String too long to pop");
+
+ _stringLength--;
+ }
+
+ string[pos] = 0;
+ _stringLength++;
+
+ // Reverse string
+ int len = resStrLen(string);
while (len--)
- *dst++ = _stringBuffer[i++];
+ *dst++ = string[len];
} else {
writeVar(0, array);
- while ((b = readArray(0, 0, i)) != 0) {
- *dst++ = b;
- i++;
+ while ((chr = readArray(0, 0, pos)) != 0) {
+ *dst++ = chr;
+ pos++;
}
}
*dst = 0;
@@ -556,7 +575,7 @@
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
} else {
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
len = resStrLen(string) + 1;
}
@@ -719,14 +738,18 @@
}
void ScummEngine_v72he::o72_addMessageToStack() {
- _stringLength = resStrLen(_scriptPointer) + 1;
- addMessageToStack(_scriptPointer, _stringBuffer, _stringLength);
+ byte chr;
- // Filter out pointless trace messages, which often flood
- if (strcmp((char *)_stringBuffer, "no trace") && strcmp((char *)_stringBuffer, "trace on"))
- debug(1,"o72_addMessageToStack(\"%s\")", _scriptPointer);
+ while ((chr = fetchScriptByte()) != 0) {
+ _stringBuffer[_stringLength] = chr;
+ _stringLength++;
- _scriptPointer += _stringLength;
+ if (_stringLength >= 4096)
+ error("String stack overflow");
+ }
+
+ _stringBuffer[_stringLength] = 0;
+ _stringLength++;
}
void ScummEngine_v72he::o72_isAnyOf() {
@@ -1030,7 +1053,7 @@
break;
case 221:
- copyScriptString(filename);
+ copyScriptString(filename, sizeof(filename));
_saveLoadFlag = pop();
_saveLoadSlot = 1;
_saveTemporaryState = true;
@@ -1166,7 +1189,7 @@
a->_talkColor = pop();
break;
case 88: // SO_ACTOR_NAME
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
loadPtrToResource(rtActorName, a->_number, string);
break;
case 89: // SO_INIT_ANIMATION
@@ -1239,7 +1262,7 @@
break;
case 225:
{
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
int slot = pop();
int len = resStrLen(string) + 1;
@@ -1280,7 +1303,7 @@
}
break;
case 125: // SO_VERB_NAME
- copyScriptString(name);
+ copyScriptString(name, sizeof(name));
loadPtrToResource(rtVerb, slot, name);
vs->type = kTextVerbType;
vs->imgindex = 0;
@@ -1394,7 +1417,7 @@
debug(1,"o72_arrayOps: case %d", subOp);
switch (subOp) {
case 7: // SO_ASSIGN_STRING
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
len = resStrLen(string) + 1;
ah = defineArray(array, kStringArray, 0, 0, 0, len);
memcpy(ah->data, string, len);
@@ -1590,7 +1613,7 @@
void ScummEngine_v72he::o72_traceStatus() {
byte string[80];
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
pop();
}
@@ -1624,7 +1647,7 @@
void ScummEngine_v72he::o72_unknownCF() {
byte string[255];
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
int len = resStrLen(string) + 1;
writeVar(0, 0);
@@ -1651,7 +1674,7 @@
byte filename[256];
mode = pop();
- copyScriptString(filename);
+ copyScriptString(filename, sizeof(filename));
debug(0,"Original filename %s", filename);
@@ -1823,15 +1846,15 @@
void ScummEngine_v72he::o72_deleteFile() {
byte filename[100];
- copyScriptString(filename);
+ copyScriptString(filename, sizeof(filename));
debug(1, "stub o72_deleteFile(%s)", filename);
}
void ScummEngine_v72he::o72_rename() {
byte oldFilename[256],newFilename[256];
- copyScriptString(newFilename);
- copyScriptString(oldFilename);
+ copyScriptString(newFilename, sizeof(newFilename));
+ copyScriptString(oldFilename, sizeof(oldFilename));
debug(1, "stub o72_rename(%s to %s)", oldFilename, newFilename);
}
@@ -2074,7 +2097,7 @@
int len, type;
// we pretend that we don't have .ini file
- copyScriptString(option);
+ copyScriptString(option, sizeof(option));
type = fetchScriptByte();
switch (type) {
@@ -2111,13 +2134,13 @@
case 43: // HE 100
case 6: // number
value = pop();
- copyScriptString(option);
+ copyScriptString(option, sizeof(option));
ConfMan.set((char *)option, value);
break;
case 77: // HE 100
case 7: // string
- copyScriptString(string);
- copyScriptString(option);
+ copyScriptString(string, sizeof(string));
+ copyScriptString(option, sizeof(option));
ConfMan.set((char *)option, (char *)string);
break;
default:
@@ -2169,13 +2192,13 @@
void ScummEngine_v72he::o72_setFilePath() {
// File related
byte filename[100];
- copyScriptString(filename);
+ copyScriptString(filename, sizeof(filename));
debug(1,"o72_setFilePath: %s", filename);
}
void ScummEngine_v72he::o72_setWindowCaption() {
byte name[100];
- copyScriptString(name);
+ copyScriptString(name, sizeof(name));
int id = fetchScriptByte();
debug(1,"o72_setWindowCaption: (%d) %s", id, name);
Index: script_v80he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v80he.cpp,v
retrieving revision 2.91
retrieving revision 2.92
diff -u -d -r2.91 -r2.92
--- script_v80he.cpp 12 Apr 2005 07:52:15 -0000 2.91
+++ script_v80he.cpp 13 Apr 2005 10:34:35 -0000 2.92
@@ -402,7 +402,7 @@
void ScummEngine_v80he::o80_getFileSize() {
byte filename[256];
- copyScriptString(filename);
+ copyScriptString(filename, sizeof(filename));
File f;
if (f.open((char *)filename) == false) {
@@ -453,9 +453,9 @@
int type;
// we pretend that we don't have .ini file
- copyScriptString(section);
- copyScriptString(name);
- copyScriptString(filename);
+ copyScriptString(section, sizeof(section));
+ copyScriptString(name, sizeof(name));
+ copyScriptString(filename, sizeof(filename));
type = fetchScriptByte();
switch (type) {
@@ -487,17 +487,17 @@
case 43: // HE 100
case 6: // number
value = pop();
- copyScriptString(section);
- copyScriptString(name);
- copyScriptString(filename);
+ copyScriptString(section, sizeof(section));
+ copyScriptString(name, sizeof(name));
+ copyScriptString(filename, sizeof(filename));
debug(1,"o80_writeConfigFile: Filename %s Section %s Name %s Value %d", filename, section, name, value);
break;
case 77: // HE 100
case 7: // string
- copyScriptString(string);
- copyScriptString(section);
- copyScriptString(name);
- copyScriptString(filename);
+ copyScriptString(string, sizeof(string));
+ copyScriptString(section, sizeof(section));
+ copyScriptString(name, sizeof(name));
+ copyScriptString(filename, sizeof(filename));
debug(1,"o80_writeConfigFile: Filename %s Section %s Name %s String %s", filename, section, name, string);
break;
default:
Index: script_v90he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v90he.cpp,v
retrieving revision 2.224
retrieving revision 2.225
diff -u -d -r2.224 -r2.225
--- script_v90he.cpp 11 Apr 2005 14:49:42 -0000 2.224
+++ script_v90he.cpp 13 Apr 2005 10:34:35 -0000 2.225
@@ -541,12 +541,12 @@
case 3:
_wizParams.processFlags |= kWPFUseFile;
_wizParams.processMode = 3;
- copyScriptString(_wizParams.filename);
+ copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
break;
case 4:
_wizParams.processFlags |= kWPFUseFile;
_wizParams.processMode = 4;
- copyScriptString(_wizParams.filename);
+ copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
_wizParams.fileWriteMode = pop();
break;
case 5:
@@ -2285,7 +2285,7 @@
case 42:
a = pop();
if (a == 2) {
- copyScriptString(string);
+ copyScriptString(string, sizeof(string));
push(-1);
} else if (a == 1) {
pop();
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.428
retrieving revision 1.429
diff -u -d -r1.428 -r1.429
--- scumm.cpp 13 Apr 2005 00:11:43 -0000 1.428
+++ scumm.cpp 13 Apr 2005 10:34:35 -0000 1.429
@@ -874,8 +874,6 @@
memset(_charsetData, 0, sizeof(_charsetData));
_charsetBufPos = 0;
memset(_charsetBuffer, 0, sizeof(_charsetBuffer));
- _stringLength = 0;
- memset(_stringBuffer, 0, sizeof(_stringBuffer));
_copyProtection = false;
_demoMode = false;
_confirmExit = false;
@@ -1646,8 +1644,16 @@
setCursorHotspot(16, 16);
}
+void ScummEngine_v72he::scummInit() {
+ ScummEngine_v60he::scummInit();
+
+ _stringLength = 1;
+ _stringStart = 1;
+ memset(_stringBuffer, 0, sizeof(_stringBuffer));
+}
+
void ScummEngine_v90he::scummInit() {
- ScummEngine_v80he::scummInit();
+ ScummEngine_v72he::scummInit();
_heObject = 0;
_heObjectNum = 0;
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.576
retrieving revision 1.577
diff -u -d -r1.576 -r1.577
--- scumm.h 13 Apr 2005 00:11:49 -0000 1.576
+++ scumm.h 13 Apr 2005 10:34:47 -0000 1.577
@@ -1168,9 +1168,6 @@
int _charsetBufPos;
byte _charsetBuffer[512];
- int _stringLength;
- byte _stringBuffer[4096];
-
bool _keepText;
void initCharset(int charset);
More information about the Scummvm-git-logs
mailing list