Skip to content

Commit c7d5ebd

Browse files
author
Bart Roossien
committed
fix(zh): Replace strcat with strlcat
1 parent 2126ecd commit c7d5ebd

File tree

24 files changed

+82
-82
lines changed

24 files changed

+82
-82
lines changed

GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,8 @@ AsciiString INI::getNextQuotedAsciiString()
782782

783783
if (strlen(token) > 1 && token[1] != '\t')
784784
{
785-
strcat(buff, " ");
786-
strcat(buff, token);
785+
strlcat(buff, " ", INI_MAX_CHARS_PER_LINE);
786+
strlcat(buff, token, INI_MAX_CHARS_PER_LINE);
787787
}
788788
else
789789
{ Int buflen=strlen(buff);
@@ -824,9 +824,9 @@ AsciiString INI::getNextAsciiString()
824824
if (token) {
825825
if (strlen(token) > 1 && token[1] != '\t')
826826
{
827-
strcat(buff, " ");
827+
strlcat(buff, " ", INI_MAX_CHARS_PER_LINE);
828828
}
829-
strcat(buff, token);
829+
strlcat(buff, token, INI_MAX_CHARS_PER_LINE);
830830
result.set(buff);
831831
} else {
832832
Int len = strlen(buff);

GeneralsMD/Code/GameEngine/Source/Common/PerfTimer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void PerfGather::reset()
353353

354354
char tmp[256];
355355
strcpy(tmp, s_buf);
356-
strcat(tmp, ".csv");
356+
strlcat(tmp, ".csv", ARRAY_SIZE(tmp));
357357

358358
s_perfStatsFile = fopen(tmp, "w");
359359
s_perfDumpOptions = options;

GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ void DumpExceptionInfo( unsigned int u, EXCEPTION_POINTERS* e_info )
617617
else
618618
{
619619
sprintf (bytestr, "%02X ", *eip_ptr);
620-
strcat (scrap, bytestr);
620+
strlcat(scrap, bytestr, ARRAY_SIZE(scrap));
621621
}
622622
eip_ptr++;
623623
}

GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,7 @@ Parameter *Parameter::ReadParameter(DataChunkInput &file)
21382138
char newName[256];
21392139
strcpy(oldName, pParm->m_string.str());
21402140
strcpy(newName, "GLA");
2141-
strcat(newName, oldName+strlen("Fundamentalist"));
2141+
strlcat(newName, oldName+strlen("Fundamentalist"), ARRAY_SIZE(newName));
21422142
pParm->m_string.set(newName);
21432143
DEBUG_LOG(("Changing Script Ref from %s to %s", oldName, newName));
21442144
}

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ Bool W3DBridge::load(BodyDamageType curDamageState)
237237
char right[_MAX_PATH];
238238

239239
strcpy(left, modelName);
240-
strcat(left, ".BRIDGE_LEFT");
240+
strlcat(left, ".BRIDGE_LEFT", _MAX_PATH);
241241
strcpy(section, modelName);
242-
strcat(section, ".BRIDGE_SPAN");
242+
strlcat(section, ".BRIDGE_SPAN", _MAX_PATH);
243243
strcpy(right, modelName);
244-
strcat(right, ".BRIDGE_RIGHT");
244+
strlcat(right, ".BRIDGE_RIGHT", _MAX_PATH);
245245

246246
m_bridgeTexture = pMgr->Get_Texture(textureFile, MIP_LEVELS_3);
247247
m_leftMtx.Make_Identity();

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3021,7 +3021,7 @@ void W3DDisplay::takeScreenShot(void)
30213021
sprintf( leafname, "%s%.3d.bmp", "sshot", frame_number++);
30223022
#endif
30233023
strcpy(pathname, TheGlobalData->getPath_UserData().str());
3024-
strcat(pathname, leafname);
3024+
strlcat(pathname, leafname, ARRAY_SIZE(pathname));
30253025
if (_access( pathname, 0 ) == -1)
30263026
done = true;
30273027
}

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ char const * GameFileClass::Set_Name( char const *filename )
189189
{
190190
static const char *localizedPathFormat = "Data/%s/Art/W3D/";
191191
sprintf(m_filePath,localizedPathFormat, GetRegistryLanguage().str());
192-
strcat( m_filePath, filename );
192+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
193193

194194
}
195195

@@ -198,7 +198,7 @@ char const * GameFileClass::Set_Name( char const *filename )
198198
{
199199
static const char *localizedPathFormat = "Data/%s/Art/Textures/";
200200
sprintf(m_filePath,localizedPathFormat, GetRegistryLanguage().str());
201-
strcat( m_filePath, filename );
201+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
202202

203203
}
204204

@@ -215,14 +215,14 @@ char const * GameFileClass::Set_Name( char const *filename )
215215
{
216216

217217
strcpy( m_filePath, W3D_DIR_PATH );
218-
strcat( m_filePath, filename );
218+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
219219

220220
}
221221
else if( isImageFileType(fileType) )
222222
{
223223

224224
strcpy( m_filePath, TGA_DIR_PATH );
225-
strcat( m_filePath, filename );
225+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
226226

227227
}
228228
else
@@ -243,14 +243,14 @@ char const * GameFileClass::Set_Name( char const *filename )
243243
{
244244

245245
strcpy( m_filePath, LEGACY_W3D_DIR_PATH );
246-
strcat( m_filePath, filename );
246+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
247247

248248
}
249249
else if( isImageFileType(fileType) )
250250
{
251251

252252
strcpy( m_filePath, LEGACY_TGA_DIR_PATH );
253-
strcat( m_filePath, filename );
253+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
254254

255255
}
256256

@@ -271,14 +271,14 @@ char const * GameFileClass::Set_Name( char const *filename )
271271
{
272272

273273
strcpy( m_filePath, TEST_W3D_DIR_PATH );
274-
strcat( m_filePath, filename );
274+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
275275

276276
}
277277
else if( isImageFileType(fileType) )
278278
{
279279

280280
strcpy( m_filePath, TEST_TGA_DIR_PATH );
281-
strcat( m_filePath, filename );
281+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
282282

283283
}
284284

@@ -295,14 +295,14 @@ char const * GameFileClass::Set_Name( char const *filename )
295295
{
296296
sprintf(m_filePath,USER_W3D_DIR_PATH, TheGlobalData->getPath_UserData().str());
297297
//strcpy( m_filePath, USER_W3D_DIR_PATH );
298-
strcat( m_filePath, filename );
298+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
299299

300300
}
301301
if( isImageFileType(fileType) )
302302
{
303303
sprintf(m_filePath,USER_TGA_DIR_PATH, TheGlobalData->getPath_UserData().str());
304304
//strcpy( m_filePath, USER_TGA_DIR_PATH );
305-
strcat( m_filePath, filename );
305+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
306306

307307
}
308308

@@ -319,7 +319,7 @@ char const * GameFileClass::Set_Name( char const *filename )
319319
{
320320
sprintf(m_filePath,MAP_PREVIEW_DIR_PATH, TheGlobalData->getPath_UserData().str());
321321
//strcpy( m_filePath, USER_TGA_DIR_PATH );
322-
strcat( m_filePath, filename );
322+
strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));
323323

324324
}
325325

GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hmorphanim.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ int HMorphAnimClass::Load_W3D(ChunkLoadClass & cload)
552552
strncpy(AnimName,header.Name,sizeof(AnimName));
553553
strncpy(HierarchyName,header.HierarchyName,sizeof(HierarchyName));
554554
strcpy(Name,HierarchyName);
555-
strcat(Name,".");
556-
strcat(Name,AnimName);
555+
strlcat(Name, ".", ARRAY_SIZE(Name));
556+
strlcat(Name, AnimName, ARRAY_SIZE(Name));
557557

558558
HTreeClass * base_pose = WW3DAssetManager::Get_Instance()->Get_HTree(HierarchyName);
559559
if (base_pose == NULL) {

GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hrawanim.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ int HRawAnimClass::Load_W3D(ChunkLoadClass & cload)
212212
}
213213

214214
strcpy(Name,aheader.HierarchyName);
215-
strcat(Name,".");
216-
strcat(Name,aheader.Name);
215+
strlcat(Name, ".", ARRAY_SIZE(Name));
216+
strlcat(Name, aheader.Name, ARRAY_SIZE(Name));
217217

218218
// TSS chasing crash bug 05/26/99
219219
WWASSERT(HierarchyName != NULL);

GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,9 +1616,9 @@ WW3DErrorType MeshGeometryClass::Load_W3D(ChunkLoadClass & cload)
16161616

16171617
if (strlen(header.ContainerName) > 0) {
16181618
strcpy(tmpname,header.ContainerName);
1619-
strcat(tmpname,".");
1619+
strlcat(tmpname, ".", namelen);
16201620
}
1621-
strcat(tmpname,header.MeshName);
1621+
strlcat(tmpname,header.MeshName, namelen);
16221622

16231623
Set_Name(tmpname);
16241624

0 commit comments

Comments
 (0)