Use strncat instead of strcat to prevent some buffer overflows

This commit is contained in:
Glenn Smith 2018-03-06 00:48:44 -05:00
parent 53f35e7fb1
commit 7769da9434
32 changed files with 147 additions and 134 deletions

View file

@ -1552,25 +1552,25 @@ const char* DInputDevice::getJoystickAxesString()
switch ( mObjInfo[i].mInst )
{
case SI_XAXIS:
dStrcat( buf, "\tX" );
dStrcat( buf, "\tX", 64 );
break;
case SI_YAXIS:
dStrcat( buf, "\tY" );
dStrcat( buf, "\tY", 64 );
break;
case SI_ZAXIS:
dStrcat( buf, "\tZ" );
dStrcat( buf, "\tZ", 64 );
break;
case SI_RXAXIS:
dStrcat( buf, "\tR" );
dStrcat( buf, "\tR", 64 );
break;
case SI_RYAXIS:
dStrcat( buf, "\tU" );
dStrcat( buf, "\tU", 64 );
break;
case SI_RZAXIS:
dStrcat( buf, "\tV" );
dStrcat( buf, "\tV", 64 );
break;
case SI_SLIDER:
dStrcat( buf, "\tS" );
dStrcat( buf, "\tS", 64 );
break;
}
}

View file

@ -158,7 +158,8 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
Platform::clearExcludedDirectories();
TempAlloc< char > tempBuf( to.size * 3 + MAX_PATH * 3 );
S32 tempBufSize = to.size * 3 + MAX_PATH * 3;
TempAlloc< char > tempBuf( tempBufSize );
// Create all the directories.
for (S32 i = 0; i < directoryInfo.size(); i++)
@ -168,7 +169,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
char* toDir = tempBuf;
Platform::makeFullPathName(fromDir + dStrlen(fromName) + (dStricmp(fromDir, fromName) ? 1 : 0), tempBuf, tempBuf.size, toName);
if(*(toDir + dStrlen(toDir) - 1) != '/')
dStrcat(toDir, "/");
dStrcat(toDir, "/", tempBufSize);
forwardslash(toDir);
if (!Platform::createPath(toDir))
@ -191,8 +192,8 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
char* toFile = tempBuf;
Platform::makeFullPathName(fileInfo[i].pFullPath + dStrlen(fromName) + (dStricmp(fileInfo[i].pFullPath, fromName) ? 1 : 0), tempBuf, tempBuf.size, toName);
dStrcat(toFile, "/");
dStrcat(toFile, fileInfo[i].pFileName);
dStrcat(toFile, "/", tempBufSize);
dStrcat(toFile, fileInfo[i].pFileName, tempBufSize);
backslash(fromFile);
backslash(toFile);