GOB: Don't use unsafe strcat and strcpy
This commit is contained in:
parent
93cdbbbf39
commit
f26ce1e4ff
8 changed files with 18 additions and 16 deletions
|
@ -514,7 +514,7 @@ void Draw::oPlaytoons_sub_F_1B(uint16 id, int16 left, int16 top, int16 right, in
|
|||
_vm->_game->_script->pop();
|
||||
}
|
||||
|
||||
strcpy(paramStr, tmpStr);
|
||||
Common::strcpy_s(paramStr, 200, tmpStr);
|
||||
|
||||
if (fontIndex >= kFontCount) {
|
||||
warning("Draw::oPlaytoons_sub_F_1B(): Font %d > Count %d", fontIndex, kFontCount);
|
||||
|
|
|
@ -917,7 +917,7 @@ uint16 Hotspots::updateInput(uint16 xPos, uint16 yPos, uint16 width, uint16 heig
|
|||
while (1) {
|
||||
// If we the edit field has enough space, add a space for the new character
|
||||
Common::strlcpy(tempStr, str, 255);
|
||||
strcat(tempStr, " ");
|
||||
Common::strcat_s(tempStr, " ");
|
||||
if ((editSize != 0) && strlen(tempStr) > editSize)
|
||||
Common::strlcpy(tempStr, str, 256);
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ void Inter::storeString(uint16 index, uint16 type, const char *value) {
|
|||
|
||||
case TYPE_IMM_INT8:
|
||||
case TYPE_VAR_INT8:
|
||||
strcpy(str, value);
|
||||
Common::strcpy_s(str, maxLength, value);
|
||||
break;
|
||||
|
||||
case TYPE_ARRAY_INT8:
|
||||
|
|
|
@ -1565,7 +1565,7 @@ void Inter_v2::o2_loadInfogramesIns(OpGobParams ¶ms) {
|
|||
varName = _vm->_game->_script->readInt16();
|
||||
|
||||
Common::strlcpy(fileName, GET_VAR_STR(varName), 16);
|
||||
strcat(fileName, ".INS");
|
||||
Common::strcat_s(fileName, ".INS");
|
||||
|
||||
_vm->_sound->infogramesLoadInstruments(fileName);
|
||||
}
|
||||
|
@ -1577,7 +1577,7 @@ void Inter_v2::o2_playInfogrames(OpGobParams ¶ms) {
|
|||
varName = _vm->_game->_script->readInt16();
|
||||
|
||||
Common::strlcpy(fileName, GET_VAR_STR(varName), 16);
|
||||
strcat(fileName, ".DUM");
|
||||
Common::strcat_s(fileName, ".DUM");
|
||||
|
||||
_vm->_sound->infogramesLoadSong(fileName);
|
||||
_vm->_sound->infogramesPlay();
|
||||
|
@ -1662,9 +1662,9 @@ int16 Inter_v2::loadSound(int16 search) {
|
|||
Common::strlcpy(sndfile, _vm->_game->_script->readString(9), 10);
|
||||
|
||||
if (type == SOUND_ADL)
|
||||
strcat(sndfile, ".ADL");
|
||||
Common::strcat_s(sndfile, ".ADL");
|
||||
else
|
||||
strcat(sndfile, ".SND");
|
||||
Common::strcat_s(sndfile, ".SND");
|
||||
|
||||
int32 dataSize;
|
||||
byte *dataPtr = _vm->_dataIO->getFile(sndfile, dataSize);
|
||||
|
|
|
@ -65,8 +65,8 @@ void Map_v1::loadMapObjects(const char *avjFile) {
|
|||
uint32 gobsPos;
|
||||
uint32 objsPos;
|
||||
|
||||
strcpy(avoName, _sourceFile);
|
||||
strcat(avoName, ".avo");
|
||||
Common::strcpy_s(avoName, sizeof(avoName) - 4, _sourceFile);
|
||||
Common::strcat_s(avoName, ".avo");
|
||||
|
||||
int32 size;
|
||||
dataBuf = _vm->_dataIO->getFile(avoName, size);
|
||||
|
@ -151,8 +151,8 @@ void Map_v1::loadSounds(Common::SeekableReadStream &data) {
|
|||
for (int i = 0; i < count; i++) {
|
||||
data.read(buf, 14);
|
||||
buf[14] = 0;
|
||||
strcat(buf, ".SND");
|
||||
strcpy(sndNames[i], buf);
|
||||
Common::strcat_s(buf, ".SND");
|
||||
Common::strcpy_s(sndNames[i], buf);
|
||||
}
|
||||
|
||||
_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[14], SOUND_SND, "diamant1.snd");
|
||||
|
|
|
@ -534,9 +534,9 @@ void Util::cleanupStr(char *str) {
|
|||
char *start, *end;
|
||||
char buf[300];
|
||||
|
||||
strcpy(buf, trStr1);
|
||||
strcat(buf, trStr2);
|
||||
strcat(buf, trStr3);
|
||||
Common::strcpy_s(buf, trStr1);
|
||||
Common::strcat_s(buf, trStr2);
|
||||
Common::strcat_s(buf, trStr3);
|
||||
|
||||
// Translating "wrong" characters
|
||||
for (size_t i = 0; i < strlen(str); i++)
|
||||
|
@ -620,6 +620,7 @@ void Util::deleteList(List *list) {
|
|||
delete list;
|
||||
}
|
||||
|
||||
#if 0
|
||||
char *Util::setExtension(char *str, const char *ext) {
|
||||
assert(str && ext);
|
||||
|
||||
|
@ -633,6 +634,7 @@ char *Util::setExtension(char *str, const char *ext) {
|
|||
strcat(str, ext);
|
||||
return str;
|
||||
}
|
||||
#endif
|
||||
|
||||
Common::String Util::setExtension(const Common::String &str, const Common::String &ext) {
|
||||
if (str.empty())
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
static void listDropFront(List *list);
|
||||
static void deleteList(List *list);
|
||||
|
||||
static char *setExtension(char *str, const char *ext);
|
||||
//static char *setExtension(char *str, const char *ext);
|
||||
static Common::String setExtension(const Common::String &str, const Common::String &ext);
|
||||
|
||||
/** Read a constant-length string out of a stream. */
|
||||
|
|
|
@ -85,7 +85,7 @@ void Variables::writeOffString(uint32 offset, const char *value) {
|
|||
uint32 length = strlen(value);
|
||||
assert((offset + length + 1) < _size);
|
||||
|
||||
strcpy((char *)(_vars + offset), value);
|
||||
Common::strcpy_s((char *)(_vars + offset), _size - offset, value);
|
||||
}
|
||||
|
||||
uint8 Variables::readVar8(uint32 var) const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue