mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Use strncpy instead of strcpy because again, buffer overflows
This commit is contained in:
parent
7769da9434
commit
79c34c68db
92 changed files with 298 additions and 279 deletions
|
|
@ -433,7 +433,7 @@ bool FileDialog::setDefaultPath(void *object, const char *index, const char *dat
|
|||
|
||||
// Copy and Backslash the path (Windows dialogs are VERY picky about this format)
|
||||
static char szPathValidate[512];
|
||||
dStrcpy(szPathValidate, data);
|
||||
dStrcpy(szPathValidate, data, 512);
|
||||
|
||||
Platform::makeFullPathName(data, szPathValidate, sizeof(szPathValidate));
|
||||
//backslash( szPathValidate );
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ StringTableEntry Platform::makeRelativePathName(const char *path, const char *to
|
|||
|
||||
// Copy the rest
|
||||
if(*branch)
|
||||
dStrcpy(bufPtr, branch + 1);
|
||||
dStrcpy(bufPtr, branch + 1, temp.size - (bufPtr - temp.ptr));
|
||||
else
|
||||
*--bufPtr = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1130,7 +1130,7 @@ static void logFree(const AllocatedHeader* hdr)
|
|||
|
||||
void enableLogging(const char* fileName)
|
||||
{
|
||||
dStrcpy(gLogFilename, fileName);
|
||||
dStrcpy(gLogFilename, fileName, 256);
|
||||
if (!gEnableLogging)
|
||||
{
|
||||
gEnableLogging = true;
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ namespace PlatformNetState
|
|||
if (addressString[0] == '[')
|
||||
{
|
||||
// Must be ipv6 notation
|
||||
dStrcpy(outAddress, addressString+1);
|
||||
dStrcpy(outAddress, addressString+1, 256);
|
||||
addressString = outAddress;
|
||||
|
||||
portString = dStrchr(outAddress, ']');
|
||||
|
|
@ -305,7 +305,7 @@ namespace PlatformNetState
|
|||
}
|
||||
else
|
||||
{
|
||||
dStrcpy(outAddress, addressString);
|
||||
dStrcpy(outAddress, addressString, 256);
|
||||
addressString = outAddress;
|
||||
|
||||
// Check to see if we have multiple ":" which would indicate this is an ipv6 address
|
||||
|
|
@ -546,7 +546,7 @@ static PolledSocket* addPolledSocket(NetSocket handleFd, SOCKET fd, S32 state,
|
|||
sock->handleFd = handleFd;
|
||||
sock->state = state;
|
||||
if (remoteAddr)
|
||||
dStrcpy(sock->remoteAddr, remoteAddr);
|
||||
dStrcpy(sock->remoteAddr, remoteAddr, 256);
|
||||
if (port != -1)
|
||||
sock->remotePort = port;
|
||||
gPolledSockets.push_back(sock);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ void RedBook::setLastError(const char * error)
|
|||
if(!error || dStrlen(error) >= sizeof(smLastError))
|
||||
setLastError("Invalid error string passed");
|
||||
else
|
||||
dStrcpy(smLastError, error);
|
||||
dStrcpy(smLastError, error, 1024);
|
||||
}
|
||||
|
||||
const char * RedBook::getLastError()
|
||||
|
|
|
|||
|
|
@ -328,9 +328,9 @@ const char * Profiler::constructProfilePath(ProfilerData * pd)
|
|||
|
||||
U32 mark = FrameAllocator::getWaterMark();
|
||||
char * buf = (char*)FrameAllocator::alloc(len+1);
|
||||
dStrcpy(buf,pd->mParent->mPath);
|
||||
dStrcat(buf,connector,len);
|
||||
dStrcat(buf,pd->mRoot->mName,len);
|
||||
dStrcpy(buf,pd->mParent->mPath,len+1);
|
||||
dStrcat(buf,connector,len+1);
|
||||
dStrcat(buf,pd->mRoot->mName,len+1);
|
||||
const char * ret = StringTable->insert(buf);
|
||||
FrameAllocator::setWaterMark(mark);
|
||||
|
||||
|
|
@ -433,7 +433,7 @@ void Profiler::dumpToFile(const char* fileName)
|
|||
AssertFatal(dStrlen(fileName) < DumpFileNameLength, "Error, dump filename too long");
|
||||
mDumpToFile = true;
|
||||
mDumpToConsole = false;
|
||||
dStrcpy(mDumpFileName, fileName);
|
||||
dStrcpy(mDumpFileName, fileName, DumpFileNameLength);
|
||||
}
|
||||
|
||||
void Profiler::hashPop(ProfilerRootData *expected)
|
||||
|
|
@ -645,11 +645,11 @@ void Profiler::dump()
|
|||
AssertFatal(success, "Cannot write profile dump to specified file!");
|
||||
char buffer[1024];
|
||||
|
||||
dStrcpy(buffer, "Profiler Data Dump:\n");
|
||||
dStrcpy(buffer, "Profiler Data Dump:\n", 1024);
|
||||
fws.write(dStrlen(buffer), buffer);
|
||||
dStrcpy(buffer, "Ordered by non-sub total time -\n");
|
||||
dStrcpy(buffer, "Ordered by non-sub total time -\n", 1024);
|
||||
fws.write(dStrlen(buffer), buffer);
|
||||
dStrcpy(buffer, "%%NSTime %% Time Invoke # Name\n");
|
||||
dStrcpy(buffer, "%%NSTime %% Time Invoke # Name\n", 1024);
|
||||
fws.write(dStrlen(buffer), buffer);
|
||||
|
||||
for(U32 i = 0; i < rootVector.size(); i++)
|
||||
|
|
@ -665,9 +665,9 @@ void Profiler::dump()
|
|||
rootVector[i]->mTotalTime = 0;
|
||||
rootVector[i]->mSubTime = 0;
|
||||
}
|
||||
dStrcpy(buffer, "\nOrdered by non-sub total time -\n");
|
||||
dStrcpy(buffer, "\nOrdered by non-sub total time -\n", 1024);
|
||||
fws.write(dStrlen(buffer), buffer);
|
||||
dStrcpy(buffer, "%%NSTime %% Time Invoke # Name\n");
|
||||
dStrcpy(buffer, "%%NSTime %% Time Invoke # Name\n", 1024);
|
||||
fws.write(dStrlen(buffer), buffer);
|
||||
|
||||
mCurrentProfilerData->mTotalTime = endHighResolutionTimer(mCurrentProfilerData->mStartTime);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue