Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Core/GameEngine/Source/Common/System/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void DebugInit(int flags)
pEnd--;
}

strcpy(theLogFileNamePrev, dirbuf);
strlcpy(theLogFileNamePrev, dirbuf, ARRAY_SIZE(theLogFileNamePrev));
strlcat(theLogFileNamePrev, gAppPrefix, ARRAY_SIZE(theLogFileNamePrev));
strlcat(theLogFileNamePrev, DEBUG_FILE_NAME_PREV, ARRAY_SIZE(theLogFileNamePrev));
if (rts::ClientInstance::getInstanceId() > 1u)
Expand All @@ -397,7 +397,7 @@ void DebugInit(int flags)
}
strlcat(theLogFileNamePrev, ".txt", ARRAY_SIZE(theLogFileNamePrev));

strcpy(theLogFileName, dirbuf);
strlcpy(theLogFileName, dirbuf, ARRAY_SIZE(theLogFileNamePrev));
strlcat(theLogFileName, gAppPrefix, ARRAY_SIZE(theLogFileNamePrev));
strlcat(theLogFileName, DEBUG_FILE_NAME, ARRAY_SIZE(theLogFileNamePrev));
if (rts::ClientInstance::getInstanceId() > 1u)
Expand Down Expand Up @@ -736,9 +736,9 @@ void ReleaseCrash(const char *reason)
return; // We are shutting down, and TheGlobalData has been freed. jba. [4/15/2003]
}

strcpy(prevbuf, TheGlobalData->getPath_UserData().str());
strlcpy(prevbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(prevbuf));
strlcat(prevbuf, RELEASECRASH_FILE_NAME_PREV, ARRAY_SIZE(prevbuf));
strcpy(curbuf, TheGlobalData->getPath_UserData().str());
strlcpy(curbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(curbuf));
strlcat(curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE(curbuf));

remove(prevbuf);
Expand Down Expand Up @@ -825,9 +825,9 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m)
char prevbuf[ _MAX_PATH ];
char curbuf[ _MAX_PATH ];

strcpy(prevbuf, TheGlobalData->getPath_UserData().str());
strlcpy(prevbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(prevbuf));
strlcat(prevbuf, RELEASECRASH_FILE_NAME_PREV, ARRAY_SIZE(prevbuf));
strcpy(curbuf, TheGlobalData->getPath_UserData().str());
strlcpy(curbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(curbuf));
strlcat(curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE(curbuf));

remove(prevbuf);
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/Common/System/GameMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2975,7 +2975,7 @@ void MemoryPoolFactory::memoryPoolUsageReport( const char* filename, FILE *appen
if( !appendToFileInstead )
{
char tmp[256];
strcpy(tmp,filename);
strlcpy(tmp, filename, ARRAY_SIZE(tmp));
strlcat(tmp, ".csv", ARRAY_SIZE(tmp));
perfStatsFile = fopen(tmp, "w");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void StdLocalFileSystem::getFileListInDirectory(const AsciiString& currentDirect
std::replace(fixedDirectory.begin(), fixedDirectory.end(), '\\', '/');
#endif

strcpy(search, fixedDirectory.c_str());
strlcpy(search, fixedDirectory.c_str(), ARRAY_SIZE(search));

Bool done = FALSE;
std::error_code ec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void Win32LocalFileSystem::getFileListInDirectory(const AsciiString& currentDire
asciisearch = originalDirectory;
asciisearch.concat(currentDirectory);
asciisearch.concat(searchName);
strcpy(search, asciisearch.str());
strlcpy(search, asciisearch.str(), ARRAY_SIZE(search));

Bool done = FALSE;

Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload)

cload.Close_Chunk();

strcpy(Name,aheader.HierarchyName);
strlcpy(Name, aheader.HierarchyName, ARRAY_SIZE(Name));
strlcat(Name, ".", ARRAY_SIZE(Name));
strlcat(Name, aheader.Name, ARRAY_SIZE(Name));

Expand Down
4 changes: 2 additions & 2 deletions Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int HModelDefClass::Load_W3D(ChunkLoadClass & cload)
*/
strlcpy(ModelName,header.Name,W3D_NAME_LEN);
strlcpy(BasePoseName,header.HierarchyName,W3D_NAME_LEN);
strcpy(Name,ModelName);
strlcpy(Name, ModelName, ARRAY_SIZE(Name));

/*
** Just allocate a node for the number of sub objects we're expecting
Expand Down Expand Up @@ -232,7 +232,7 @@ bool HModelDefClass::read_connection(ChunkLoadClass & cload,HmdlNodeDefStruct *
return false;
}

strcpy(node->RenderObjName,ModelName);
strlcpy(node->RenderObjName, ModelName, ARRAY_SIZE(node->RenderObjName));
strlcat(node->RenderObjName, ".", ARRAY_SIZE(node->RenderObjName));
strlcat(node->RenderObjName, con.RenderObjName, ARRAY_SIZE(node->RenderObjName));

Expand Down
6 changes: 3 additions & 3 deletions Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ void RingRenderObjClass::Set_Name(const char * name)
{
WWASSERT(name != NULL);
WWASSERT(strlen(name) < 2*W3D_NAME_LEN);
strcpy(Name,name);
strlcpy(Name, name, ARRAY_SIZE(Name));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use assert like in SphereRenderObjClass::Set_Name

}

/***********************************************************************************************
Expand Down Expand Up @@ -1206,7 +1206,7 @@ RingPrototypeClass::RingPrototypeClass (void)
RingPrototypeClass::RingPrototypeClass(RingRenderObjClass *ring)
{
::memset (&Definition, 0, sizeof (Definition));
::strcpy (Definition.Name, ring->Get_Name ());
strlcpy(Definition.Name, ring->Get_Name(), ARRAY_SIZE(Definition.Name));

Definition.AnimDuration = ring->AnimDuration;
Definition.Attributes = ring->Get_Flags ();
Expand Down Expand Up @@ -1237,7 +1237,7 @@ RingPrototypeClass::RingPrototypeClass(RingRenderObjClass *ring)
filename = name;
}

::strcpy (Definition.TextureName, filename);
strlcpy(Definition.TextureName, filename, ARRAY_SIZE(Definition.TextureName));
}

//
Expand Down
8 changes: 4 additions & 4 deletions Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ const char * SphereRenderObjClass::Get_Name(void) const
void SphereRenderObjClass::Set_Name(const char * name)
{
WWASSERT(name != NULL);
WWASSERT(strlen(name) < 2*W3D_NAME_LEN);
strcpy(Name,name);
const size_t nameLen = strlcpy(Name, name, ARRAY_SIZE(Name));
(void)nameLen; WWASSERT(nameLen < ARRAY_SIZE(Name));
}


Expand Down Expand Up @@ -1162,7 +1162,7 @@ SpherePrototypeClass::SpherePrototypeClass (void)
SpherePrototypeClass::SpherePrototypeClass(SphereRenderObjClass *sphere)
{
::memset (&Definition, 0, sizeof (Definition));
::strcpy (Definition.Name, sphere->Get_Name ());
strlcpy(Definition.Name, sphere->Get_Name(), ARRAY_SIZE(Definition.Name));

Definition.DefaultAlpha = sphere->Get_Default_Alpha ();
Definition.AnimDuration = sphere->AnimDuration;
Expand Down Expand Up @@ -1190,7 +1190,7 @@ SpherePrototypeClass::SpherePrototypeClass(SphereRenderObjClass *sphere)
filename = name;
}

::strcpy (Definition.TextureName, filename);
strlcpy(Definition.TextureName, filename, ARRAY_SIZE(Definition.TextureName));

}

Expand Down
6 changes: 3 additions & 3 deletions Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@
// Copy all characters from start to end (excluding 'end')
// into the w3d_name buffer. Then capitalize the string.
int num_chars = end - start;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t to get rid of compiler warning

WWASSERT(num_chars <= W3D_NAME_LEN);
strlcpy(w3d_name, start, min(W3D_NAME_LEN, num_chars));
const size_t nameLen = strlcpy(w3d_name, start, min(W3D_NAME_LEN, num_chars));
(void)nameLen; WWASSERT(nameLen < min(W3D_NAME_LEN, num_chars));

Check warning on line 537 in Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-debug+t+e

'<': signed/unsigned mismatch

Check warning on line 537 in Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp

View workflow job for this annotation

GitHub Actions / Build Generals / win32-debug+t+e

'<': signed/unsigned mismatch
strupr(w3d_name);
}

Expand Down Expand Up @@ -565,7 +565,7 @@
buffer[0] = 0;
return buffer;
}
strcpy(buffer, w3d_name);
strlcpy(buffer, w3d_name, ARRAY_SIZE(buffer));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same Assert as in sphereobj.cpp

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert was not changed

char *dot = strchr(buffer, '.');
if (dot)
*dot = 0;
Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@
char ext[ 10 ];

if (m_findStart==0)
m_findStart=time(NULL);

Check warning on line 668 in Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-debug+t+e

'=': conversion from 'time_t' to 'int', possible loss of data

Check warning on line 668 in Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp

View workflow job for this annotation

GitHub Actions / Build Generals / win32-debug+t+e

'=': conversion from 'time_t' to 'int', possible loss of data

Check warning on line 668 in Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp

View workflow job for this annotation

GitHub Actions / Build Generals / win32-profile+t+e

'=': conversion from 'time_t' to 'int', possible loss of data

Check warning on line 668 in Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp

View workflow job for this annotation

GitHub Actions / Build Generals / win32+t+e

'=': conversion from 'time_t' to 'int', possible loss of data

Check warning on line 668 in Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32+t+e

'=': conversion from 'time_t' to 'int', possible loss of data

Check warning on line 668 in Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-profile+t+e

'=': conversion from 'time_t' to 'int', possible loss of data

if((time(NULL)-m_findStart) > 30) // try for 30 seconds
{
Expand Down Expand Up @@ -1719,7 +1719,7 @@

// Concatenate the registry key together

strcpy( regkey, szRegistryRoot );
strlcpy(regkey, szRegistryRoot, ARRAY_SIZE(regkey));
if( regkey[ strlen( regkey ) - 1 ] != '\\' )
{
strlcat(regkey, "\\Download", ARRAY_SIZE(regkey));
Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WWLib/Except.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ void Register_Thread_ID(unsigned long thread_id, char *thread_name, bool main_th

ThreadInfoType *thread = new ThreadInfoType;
thread->ThreadID = thread_id;
strcpy(thread->ThreadName, thread_name);
strlcpy(thread->ThreadName, thread_name, ARRAY_SIZE(thread->ThreadName));
thread->Main = main_thread;
thread->ThreadHandle = INVALID_HANDLE_VALUE;
ThreadList.Add(thread);
Expand Down
4 changes: 2 additions & 2 deletions Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void SimpleFileFactoryClass::Prepend_Sub_Directory( const char * sub_directory )

// Ensure sub_directory ends with a slash, and append a semicolon
char temp_sub_dir[1024];
strcpy(temp_sub_dir, sub_directory);
strlcpy(temp_sub_dir, sub_directory, ARRAY_SIZE(temp_sub_dir));
if (temp_sub_dir[sub_len - 1] != '\\') {
temp_sub_dir[sub_len] = '\\';
temp_sub_dir[sub_len + 1] = 0;
Expand Down Expand Up @@ -181,7 +181,7 @@ void SimpleFileFactoryClass::Append_Sub_Directory( const char * sub_directory )

// Ensure sub_directory ends with a slash
char temp_sub_dir[1024];
strcpy(temp_sub_dir, sub_directory);
strlcpy(temp_sub_dir, sub_directory, ARRAY_SIZE(temp_sub_dir));
if (temp_sub_dir[sub_len - 1] != '\\') {
temp_sub_dir[sub_len] = '\\';
temp_sub_dir[sub_len + 1] = 0;
Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WWLib/ini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ int INIClass::Load(Straw & ffile)
if (ptr != NULL) *ptr = '\0';
strtrim(buffer);
char section[64];
strcpy(section, buffer);
strlcpy(section, buffer, ARRAY_SIZE(section));

/*
** Read in the entries of this section.
Expand Down
6 changes: 3 additions & 3 deletions Core/Libraries/Source/WWVegas/WWLib/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void RegistryClass::Save_Registry_Tree(char *path, INIClass *ini)
** See if there are sub keys.
*/
char new_key_path[512];
strcpy(new_key_path, path);
strlcpy(new_key_path, path, ARRAY_SIZE(new_key_path));
strlcat(new_key_path, "\\", ARRAY_SIZE(new_key_path));
strlcat(new_key_path, name, ARRAY_SIZE(new_key_path));

Expand Down Expand Up @@ -564,7 +564,7 @@ void RegistryClass::Load_Registry(const char *filename, char *old_path, char *ne
** Build the new path to use in the registry.
*/
char *section_name = section->Section;
strcpy(path, new_path);
strlcpy(path, new_path, ARRAY_SIZE(path));
char *cut = strstr(section_name, old_path);
if (cut) {
strlcat(path, cut + old_path_len, ARRAY_SIZE(path));
Expand Down Expand Up @@ -693,7 +693,7 @@ void RegistryClass::Delete_Registry_Tree(char *path)
** See if there are sub keys.
*/
char new_key_path[512];
strcpy(new_key_path, path);
strlcpy(new_key_path, path, ARRAY_SIZE(new_key_path));
strlcat(new_key_path, "\\", ARRAY_SIZE(new_key_path));
strlcat(new_key_path, name, ARRAY_SIZE(new_key_path));

Expand Down
4 changes: 2 additions & 2 deletions Core/Libraries/Source/WWVegas/WWLib/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define _WIN32_WINNT 0x0400

Check warning on line 19 in Core/Libraries/Source/WWVegas/WWLib/thread.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-debug+t+e

'_WIN32_WINNT': macro redefinition

Check warning on line 19 in Core/Libraries/Source/WWVegas/WWLib/thread.cpp

View workflow job for this annotation

GitHub Actions / Build Generals / win32-debug+t+e

'_WIN32_WINNT': macro redefinition

Check warning on line 19 in Core/Libraries/Source/WWVegas/WWLib/thread.cpp

View workflow job for this annotation

GitHub Actions / Build Generals / win32-profile+t+e

'_WIN32_WINNT': macro redefinition

Check warning on line 19 in Core/Libraries/Source/WWVegas/WWLib/thread.cpp

View workflow job for this annotation

GitHub Actions / Build Generals / win32+t+e

'_WIN32_WINNT': macro redefinition

Check warning on line 19 in Core/Libraries/Source/WWVegas/WWLib/thread.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32+t+e

'_WIN32_WINNT': macro redefinition

Check warning on line 19 in Core/Libraries/Source/WWVegas/WWLib/thread.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-profile+t+e

'_WIN32_WINNT': macro redefinition

#include "thread.h"
#include "Except.h"
Expand All @@ -34,8 +34,8 @@
ThreadClass::ThreadClass(const char *thread_name, ExceptionHandlerType exception_handler) : handle(0), running(false), thread_priority(0)
{
if (thread_name) {
assert(strlen(thread_name) < sizeof(ThreadName) - 1);
strcpy(ThreadName, thread_name);
size_t nameLen = strlcpy(ThreadName, thread_name, ARRAY_SIZE(ThreadName));
(void)nameLen; assert(nameLen < ARRAY_SIZE(ThreadName));
} else {
strcpy(ThreadName, "No name");;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/debug/debug_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ void Debug::UpdateFrameStatus(FrameHashEntry &entry)
entry.frameType==FrameTypeCheck)
wsprintf(help,"%s(%i)",entry.fileOrGroup,entry.line);
else
strcpy(help,entry.fileOrGroup);
strlcpy(help, entry.fileOrGroup, ARRAY_SIZE(help));

// update frame status
bool active=entry.frameType!=FrameTypeLog;
Expand Down
18 changes: 8 additions & 10 deletions Core/Libraries/Source/debug/debug_io_flat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,15 @@ void DebugIOFlat::OutputStream::Delete(const char *path)
char help[512];
if (path[0]&&(path[1]==':'||(path[0]=='\\'&&path[1]=='\\')))
{
strcpy(help,path);
strcpy(help+pathLen,fileNameOnly);
help[ext-fileNameOnly+pathLen]=0;
strlcpy(help, path, ARRAY_SIZE(help));
strlcat(help, fileNameOnly, ARRAY_SIZE(help));
}
else
{
// no, relative path given
strcpy(help,m_fileName);
strcpy(help+(fileNameOnly-m_fileName),path);
strcpy(help+(fileNameOnly-m_fileName)+pathLen,fileNameOnly);
help[ext-fileNameOnly+pathLen+(fileNameOnly-m_fileName)]=0;
strlcpy(help, m_fileName, ARRAY_SIZE(help));
strlcat(help, path, ARRAY_SIZE(help));
strlcat(help, fileNameOnly, ARRAY_SIZE(help));
}
if (++run)
wsprintf(help+strlen(help),"(%i)%s",run,ext);
Expand Down Expand Up @@ -268,7 +266,7 @@ void DebugIOFlat::ExpandMagic(const char *src, const char *splitName, char *buf)
case 'n':
case 'N':
if (splitName&&strlen(splitName)<250)
strcpy(help,splitName);
strlcpy(help, splitName, ARRAY_SIZE(help));
break;
default:
*dst++=src[-1];
Expand All @@ -277,7 +275,7 @@ void DebugIOFlat::ExpandMagic(const char *src, const char *splitName, char *buf)
unsigned len=strlen(help);
if (dst-buf+len>250)
break;
strcpy(dst,help);
strlcpy(dst, help, ARRAY_SIZE(dst));
dst+=len;
}
strcpy(dst,".log");
Expand Down Expand Up @@ -418,7 +416,7 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd,
// add [ <filename> [ <size in kb> ] ]
__ASSERT(m_firstStream==NULL);

strcpy(m_baseFilename,argn?argv[0]:"*eMN");
strlcpy(m_baseFilename, argn?argv[0]:"*eMN", ARRAY_SIZE(m_baseFilename));

char fn[256];
ExpandMagic(m_baseFilename,NULL,fn);
Expand Down
6 changes: 3 additions & 3 deletions GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ UnsignedInt INI::load( AsciiString filename, INILoadType loadType, Xfer *pXfer )
if (parse)
{
#ifdef DEBUG_CRASHING
strcpy(m_curBlockStart, m_buffer);
strlcpy(m_curBlockStart, m_buffer, ARRAY_SIZE(m_curBlockStart));
#endif
try {
(*parse)( this );
Expand Down Expand Up @@ -768,7 +768,7 @@ AsciiString INI::getNextQuotedAsciiString()
Bool done=FALSE;
if ((strLen=strlen(token)) > 1)
{
strcpy(buff, &token[1]); //skip the starting quote
strlcpy(buff, &token[1], ARRAY_SIZE(buff)); //skip the starting quote
//Check for end of quoted string. Checking here fixes cases where quoted string on same line with other data.
if (buff[strLen-2]=='"') //skip ending quote if present
{ buff[strLen-2]='\0';
Expand Down Expand Up @@ -817,7 +817,7 @@ AsciiString INI::getNextAsciiString()
buff[0] = 0;
if (strlen(token) > 1)
{
strcpy(buff, &token[1]);
strlcpy(buff, &token[1], ARRAY_SIZE(buff));
}

token = getNextTokenOrNull(getSepsQuote());
Expand Down
4 changes: 2 additions & 2 deletions GeneralsMD/Code/GameEngine/Source/Common/PerfTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ void PerfGather::reset()
{
PerfGather::termPerfDump();

strcpy(s_buf, fname);
strlcpy(s_buf, fname, _MAX_PATH);

char tmp[256];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_MAX_PATH

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely _MAX_PATH

strcpy(tmp, s_buf);
strlcpy(tmp, s_buf, ARRAY_SIZE(tmp));
strlcat(tmp, ".csv", ARRAY_SIZE(tmp));

s_perfStatsFile = fopen(tmp, "w");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,14 +847,15 @@ static AsciiString getMapLeafAndDirName(const AsciiString& in)
// ------------------------------------------------------------------------------------------------
static AsciiString removeExtension(const AsciiString& in)
{
char buf[1024];
strcpy(buf, in.str());
char* p = strrchr(buf, '.');
if (p)
if (const char* end = in.reverseFind('.'))
{
*p = 0;
const char* begin = in.str();
return AsciiString(begin, end - begin);
}
else
{
return in;
}
return AsciiString(buf);
}

// ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1623,7 +1624,7 @@ void GameState::xfer( Xfer *xfer )
{
char string[ _MAX_PATH ];

strcpy( string, TheGlobalData->m_mapName.str() );
strlcpy(string, TheGlobalData->m_mapName.str(), ARRAY_SIZE(string));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string copy is unnecessary. We can use TheGlobalData->m_mapName directly with AsciiString::reverseFind.

char *p = strrchr( string, '\\' );
if( p == NULL )
saveGameInfo->mapLabel = TheGlobalData->m_mapName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,9 @@ void JoinDirectConnectGame()
AsciiString ipstring;
asciientry.nextToken(&ipstring, "(");

char ipstr[16];
strcpy(ipstr, ipstring.str());

Int ip1, ip2, ip3, ip4;
sscanf(ipstr, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4);
Int numFields = sscanf(ipstring.str(), "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4);
(void)numFields; DEBUG_ASSERTCRASH(numFields == 4, ("JoinDirectConnectGame - invalid IP address format: %s", ipstring.str()));

DEBUG_LOG(("JoinDirectConnectGame - joining at %d.%d.%d.%d", ip1, ip2, ip3, ip4));

Expand Down
Loading
Loading