Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ WW3DErrorType CollectionDefClass::Load(ChunkLoadClass & cload)
if (cload.Read(&header,sizeof(header)) != sizeof(header)) goto Error;
if (!cload.Close_Chunk()) goto Error;

strncpy(Name,header.Name,W3D_NAME_LEN);
strlcpy(Name,header.Name,W3D_NAME_LEN);
ObjectNames.Resize(header.RenderObjectCount);

while (cload.Open_Chunk()) {
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 @@ -264,7 +264,7 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload)
WWASSERT(HierarchyName != NULL);
WWASSERT(aheader.HierarchyName != NULL);
WWASSERT(sizeof(HierarchyName) >= W3D_NAME_LEN);
strncpy(HierarchyName,aheader.HierarchyName,W3D_NAME_LEN);
strlcpy(HierarchyName,aheader.HierarchyName,W3D_NAME_LEN);

HTreeClass * base_pose = WW3DAssetManager::Get_Instance()->Get_HTree(HierarchyName);
if (base_pose == NULL) {
Expand Down
6 changes: 2 additions & 4 deletions Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,8 @@ int HModelDefClass::Load_W3D(ChunkLoadClass & cload)
/*
** process the header info
*/
strncpy(ModelName,header.Name,W3D_NAME_LEN);
ModelName[W3D_NAME_LEN - 1] = 0;
strncpy(BasePoseName,header.HierarchyName,W3D_NAME_LEN);
BasePoseName[W3D_NAME_LEN-1] = 0;
strlcpy(ModelName,header.Name,W3D_NAME_LEN);
strlcpy(BasePoseName,header.HierarchyName,W3D_NAME_LEN);
strcpy(Name,ModelName);

/*
Expand Down
4 changes: 2 additions & 2 deletions Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ static void Get_W3D_Name (const char *filename, char *w3d_name)

// Copy all characters from start to end (excluding 'end')
// into the w3d_name buffer. Then capitalize the string.
memset(w3d_name, 0, W3D_NAME_LEN); // blank out the buffer
int num_chars = end - start;
strncpy(w3d_name, start, num_chars < W3D_NAME_LEN ? num_chars : W3D_NAME_LEN-1);
WWASSERT(num_chars <= W3D_NAME_LEN);
strlcpy(w3d_name, start, min(W3D_NAME_LEN, num_chars));
strupr(w3d_name);
}

Expand Down
18 changes: 9 additions & 9 deletions Core/Libraries/Source/WWVegas/WWDownload/Download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// Download.cpp : Implementation of CDownload
#include "DownloadDebug.h"
#include "Download.h"
#include "stringex.h"
#include <mmsystem.h>
#include <assert.h>
#include <direct.h>
Expand Down Expand Up @@ -69,15 +70,15 @@ HRESULT CDownload::DownloadFile(LPCSTR server, LPCSTR username, LPCSTR password,
_mkdir("download");

// Copy parameters to member variables.
strncpy( m_Server, server, sizeof( m_Server ) );
strncpy( m_Login, username, sizeof( m_Login ) );
strncpy( m_Password, password, sizeof( m_Password ) );
strncpy( m_File, file, sizeof( m_File ) );
strncpy( m_LocalFile, localfile, sizeof( m_LocalFile ) );
strlcpy( m_Server, server, sizeof( m_Server ) );
strlcpy( m_Login, username, sizeof( m_Login ) );
strlcpy( m_Password, password, sizeof( m_Password ) );
strlcpy( m_File, file, sizeof( m_File ) );
strlcpy( m_LocalFile, localfile, sizeof( m_LocalFile ) );

strncpy( m_LastLocalFile, localfile, sizeof( m_LastLocalFile ) );
strlcpy( m_LastLocalFile, localfile, sizeof( m_LastLocalFile ) );

strncpy( m_RegKey, regkey, sizeof( m_RegKey ) );
strlcpy( m_RegKey, regkey, sizeof( m_RegKey ) );
m_TryResume = tryresume;
m_StartPosition=0;

Expand Down Expand Up @@ -113,8 +114,7 @@ HRESULT CDownload::GetLastLocalFile(char *local_file, int maxlen) {
if (local_file==0)
return(E_FAIL);

strncpy(local_file, m_LastLocalFile, maxlen);
local_file[maxlen-1]=0;
strlcpy(local_file, m_LastLocalFile, maxlen);

return(S_OK);
}
Expand Down
12 changes: 6 additions & 6 deletions Core/Libraries/Source/WWVegas/WWDownload/FTP.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <errno.h>
//#include "wlib/wstring.h"

#include "stringex.h"
#include "DownloadDebug.h"

// umm... what?? BGC 3/27/03
Expand Down Expand Up @@ -324,7 +325,7 @@
char buffer[ 256 ];
int iReply, error;

strncpy( m_szServerName, szServerName, 128 );
strlcpy( m_szServerName, szServerName, sizeof(m_szServerName));

if( m_iStatus == FTPSTAT_INIT )
{
Expand Down Expand Up @@ -487,8 +488,8 @@
char command[ 256 ];
int iReply;

strncpy( m_szUserName, szUserName, 128 );
strncpy( m_szPassword, szPassword, 128 );
strlcpy( m_szUserName, szUserName, sizeof(m_szUserName));
strlcpy( m_szPassword, szPassword, sizeof(m_szPassword));

memset( command, 0, 256 );

Expand Down Expand Up @@ -665,7 +666,7 @@
char ext[ 10 ];

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

Check warning on line 669 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 669 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 669 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

Check warning on line 669 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 669 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 669 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

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

//char str[ 256 ];

strncpy( m_szLocalFileName, szLocalFileName, 256 );
strlcpy( m_szLocalFileName, szLocalFileName, sizeof(m_szLocalFileName));

// Open local file

Expand Down Expand Up @@ -1830,8 +1831,7 @@
const char *cptr=filename;
while(cptr=strchr(cptr,'\\'))
{
memset(tempstr,0,256);
strncpy(tempstr,filename,cptr-filename);
strlcpy(tempstr,filename,cptr-filename + 1);
sprintf(newdir,"%s\\%s",rootdir, tempstr);
if (!CreateDirectory(newdir, NULL))
return false;
Expand Down
4 changes: 2 additions & 2 deletions Core/Libraries/Source/WWVegas/WWLib/TARGA.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ long Targa::Save(const char* name, long flags, bool addextension)
if (!error) {

mExtension.ExtSize = 495;
strncpy(mExtension.SoftID, "Denzil's Targa Code", 41);
strlcpy(mExtension.SoftID, "Denzil's Targa Code", sizeof(mExtension.SoftID));
mExtension.SoftVer.Number = (1 * 100);
mExtension.SoftVer.Letter = 0;

Expand All @@ -735,7 +735,7 @@ long Targa::Save(const char* name, long flags, bool addextension)
if (!error)
{
footer.Developer = 0;
strncpy(footer.Signature, TGA2_SIGNATURE, 16);
strlcpy(footer.Signature, TGA2_SIGNATURE, sizeof(footer.Signature));
footer.RsvdChar = '.';
footer.BZST = 0;

Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ void CPUDetectClass::Init_Processor_String()
case INTEL_PROCESSOR_PENTIUM4: str+="Pentium4"; break;
}
}
strncpy(ProcessorString,str.str(),sizeof(ProcessorString));
strlcpy(ProcessorString,str.str(),sizeof(ProcessorString));
}

}
Expand Down
6 changes: 2 additions & 4 deletions Core/Libraries/Source/WWVegas/WWLib/ini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,8 +1150,7 @@ bool INIClass::Put_TextBlock(char const * section, char const * text)

char buffer[128];

strncpy(buffer, text, 75);
buffer[75] = '\0';
strlcpy(buffer, text, 76);

char b[32];
sprintf(b, "%d", index);
Expand Down Expand Up @@ -1724,8 +1723,7 @@ int INIClass::Get_String(char const * section, char const * entry, char const *
buffer[0] = '\0';
return(0);
} else {
strncpy(buffer, defvalue, size);
buffer[size-1] = '\0';
strlcpy(buffer, defvalue, size);
strtrim(buffer);
return(strlen(buffer));
}
Expand Down
1 change: 1 addition & 0 deletions Core/Libraries/Source/debug/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ target_include_directories(core_debug INTERFACE

target_link_libraries(core_debug PRIVATE
core_config
core_wwcommon
corei_always
)
10 changes: 5 additions & 5 deletions Core/Libraries/Source/debug/debug_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// Debug class implementation
//////////////////////////////////////////////////////////////////////////////
#include "_pch.h"
#include <stringex.h>
#include <stdlib.h>
#include <Utility/stdio_adapter.h>
#include <string.h>
Expand Down Expand Up @@ -729,8 +730,7 @@ Debug& Debug::operator<<(const char *str)

void Debug::SetPrefixAndRadix(const char *prefix, int radix)
{
strncpy(m_prefix,prefix?prefix:"",sizeof(m_prefix)-1);
m_prefix[sizeof(m_prefix)-1]=0;
strlcpy(m_prefix,prefix?prefix:"",sizeof(m_prefix));
m_radix=radix;
}

Expand Down Expand Up @@ -1423,11 +1423,11 @@ void Debug::SetBuildInfo(const char *version,
const char *buildDate)
{
if (version)
strncpy(Instance.m_version,version,sizeof(Instance.m_version)-1);
strlcpy(Instance.m_version,version,sizeof(Instance.m_version));
if (internalVersion)
strncpy(Instance.m_intVersion,internalVersion,sizeof(Instance.m_intVersion)-1);
strlcpy(Instance.m_intVersion,internalVersion,sizeof(Instance.m_intVersion));
if (buildDate)
strncpy(Instance.m_buildDate,buildDate,sizeof(Instance.m_buildDate)-1);
strlcpy(Instance.m_buildDate,buildDate,sizeof(Instance.m_buildDate));
}

void Debug::WriteBuildInfo(void)
Expand Down
11 changes: 4 additions & 7 deletions Core/Libraries/Source/debug/debug_io_flat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// Debug I/O class flat (flat or split log file)
//////////////////////////////////////////////////////////////////////////////
#include "_pch.h"
#include "stringex.h"
#include <stdlib.h>
#include <new> // needed for placement new prototype

Expand Down Expand Up @@ -428,8 +429,7 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd,
// copy <directory>
if (argn)
{
strncpy(m_copyDir,argv[0],sizeof(m_copyDir)-1);
m_copyDir[sizeof(m_copyDir)-1]=0;
strlcpy(m_copyDir,argv[0],sizeof(m_copyDir));
}
}
else if (!strcmp(cmd,"splitadd"))
Expand Down Expand Up @@ -460,11 +460,8 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd,
if (!cur->stringTypes)
cur->stringTypes=0xffffffff;

strncpy(cur->items,argv[1],sizeof(cur->items)-1);
cur->items[sizeof(cur->items)-1]=0;

strncpy(cur->name,argv[2],sizeof(cur->name)-1);
cur->name[sizeof(cur->name)-1]=0;
strlcpy(cur->items,argv[1],sizeof(cur->items));
strlcpy(cur->name,argv[2],sizeof(cur->name));

// create our filename, search for stream with same filename
char fn[256];
Expand Down
10 changes: 4 additions & 6 deletions Core/Libraries/Source/debug/debug_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// Stack walker
//////////////////////////////////////////////////////////////////////////////
#include "_pch.h"
#include "stringex.h"
#include <imagehlp.h>

// Definitions to allow run-time linking to the dbghelp.dll functions.
Expand Down Expand Up @@ -250,8 +251,7 @@ void DebugStackwalk::Signature::GetSymbol(unsigned addr,

char *p=strrchr(symbolBuffer,'\\'); // use filename only, strip off path
p=p?p+1:symbolBuffer;
strncpy(bufMod,p,sizeMod);
bufMod[sizeMod-1]=0;
strlcpy(bufMod,p,sizeMod);
}
if (relMod)
*relMod=addr-modBase;
Expand All @@ -266,8 +266,7 @@ void DebugStackwalk::Signature::GetSymbol(unsigned addr,
DWORD displacement;
if (gDbg._SymGetSymFromAddr((HANDLE)GetCurrentProcessId(),addr,&displacement,symPtr))
{
strncpy(bufSym,symPtr->Name,sizeSym);
bufSym[sizeSym-1]=0;
strlcpy(bufSym,symPtr->Name,sizeSym);
if (relSym)
*relSym=displacement;
}
Expand All @@ -288,8 +287,7 @@ void DebugStackwalk::Signature::GetSymbol(unsigned addr,
{
char *p=strrchr(line.FileName,'\\'); // use filename only, strip off path
p=p?p+1:line.FileName;
strncpy(bufFile,p,sizeFile);
bufFile[sizeFile-1]=0;
strlcpy(bufFile,p,sizeFile);
if (linePtr)
*linePtr=line.LineNumber;
if (relLine)
Expand Down
1 change: 1 addition & 0 deletions Core/Libraries/Source/profile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ target_include_directories(core_profile INTERFACE

target_link_libraries(core_profile PRIVATE
core_config
core_wwcommon
corei_always
)
6 changes: 3 additions & 3 deletions Core/Libraries/Source/profile/profile_highlevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// High level profiling
//////////////////////////////////////////////////////////////////////////////
#include "_pch.h"
#include "stringex.h"
#include <new>
#include <Utility/stdio_adapter.h>

Expand Down Expand Up @@ -91,9 +92,8 @@ ProfileHighLevel::Block::Block(const char *name)
m_idTime=AddProfile(name,NULL,"msec",6,-4);

char help[256];
strncpy(help,name,sizeof(help));
help[sizeof(help)-1-2]=0;
strcat(help,".c");
strlcpy(help, name, sizeof(help) - 2);
strlcat(help, ".c", sizeof(help));
AddProfile(help,NULL,"calls",6,0).Increment();

ProfileGetTime(m_start);
Expand Down
4 changes: 2 additions & 2 deletions Core/Tools/ImagePacker/Source/ImagePacker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <assert.h>

// USER INCLUDES //////////////////////////////////////////////////////////////
#include "stringex.h"
#include "Common/Debug.h"
#include "WWLib/TARGA.H"
#include "Resource.h"
Expand Down Expand Up @@ -844,8 +845,7 @@ void ImagePacker::addImage( char *path )
strcpy( info->m_filenameOnly, c );

info->m_filenameOnlyNoExt = new char[ nameLen - 4 + 1 ];
strncpy( info->m_filenameOnlyNoExt, c, nameLen - 4 );
info->m_filenameOnlyNoExt[ nameLen - 4 ] = '\0';
strlcpy( info->m_filenameOnlyNoExt, c, nameLen - 4 + 1 );

// assign to array
m_imageList[ m_imageCount++ ] = info;
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Source/Common/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void RecorderClass::cleanUpReplayFile( void )
if (TheGlobalData->m_saveStats)
{
char fname[_MAX_PATH+1];
strncpy(fname, TheGlobalData->m_baseStatsDir.str(), _MAX_PATH);
strlcpy(fname, TheGlobalData->m_baseStatsDir.str(), ARRAY_SIZE(fname));
strncat(fname, m_fileName.str(), _MAX_PATH - strlen(fname));
DEBUG_LOG(("Saving replay to %s", fname));
AsciiString oldFname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ void ThingTemplate::initForLTA(const AsciiString& name)
m_nameString = name;

char buffer[1024];
strncpy(buffer, name.str(), sizeof(buffer));
strlcpy(buffer, name.str(), sizeof(buffer));
int i=0;
for (; buffer[i]; i++) {
if (buffer[i] == '/') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1718,8 +1718,7 @@ WindowMsgHandledType WOLQuickMatchMenuSystem( GameWindow *window, UnsignedInt ms
req.QM.discons = numDiscons;


strncpy(req.QM.pings, TheGameSpyInfo->getPingString().str(), 17);
req.QM.pings[16] = 0;
strlcpy(req.QM.pings, TheGameSpyInfo->getPingString().str(), sizeof(req.QM.pings));

req.QM.botID = TheGameSpyConfig->getQMBotID();
req.QM.roomID = TheGameSpyConfig->getQMChannel();
Expand Down
6 changes: 2 additions & 4 deletions Generals/Code/GameEngine/Source/GameClient/MapUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ static UnsignedInt calcCRC( AsciiString dirName, AsciiString fname )
length = strlen( tempBuf );
if( length >= 4 )
{
memset( filenameBuf, '\0', _MAX_PATH);
strncpy( filenameBuf, tempBuf, length - 4);
strlcpy( filenameBuf, tempBuf, length - 4 + 1);
}

File *fp;
Expand Down Expand Up @@ -242,8 +241,7 @@ static Bool loadMap( AsciiString filename )
length = strlen( tempBuf );
if( length >= 4 )
{
memset( filenameBuf, '\0', _MAX_PATH);
strncpy( filenameBuf, tempBuf, length - 4);
strlcpy( filenameBuf, tempBuf, length - 4 + 1);
}

CachedFileInputStream fileStrm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,7 @@ void BuddyThreadClass::errorCallback( GPConnection *con, GPErrorArg *arg )
errorResponse.result = arg->result;
errorResponse.arg.error.errorCode = arg->errorCode;
errorResponse.arg.error.fatal = arg->fatal;
strncpy(errorResponse.arg.error.errorString, arg->errorString, MAX_BUDDY_CHAT_LEN);
errorResponse.arg.error.errorString[MAX_BUDDY_CHAT_LEN-1] = 0;
strlcpy(errorResponse.arg.error.errorString, arg->errorString, MAX_BUDDY_CHAT_LEN);
m_isConnecting = m_isConnected = false;
TheGameSpyBuddyMessageQueue->addResponse( errorResponse );
if (m_isdeleting)
Expand Down
Loading
Loading