Use strncpy instead of strcpy because again, buffer overflows

This commit is contained in:
Glenn Smith 2018-03-06 01:59:05 -05:00
parent 7769da9434
commit 79c34c68db
92 changed files with 298 additions and 279 deletions

View file

@ -431,7 +431,7 @@ bool DbgFileView::findMouseOverVariable()
{
S32 stringPosition = pt.x - gFileXOffset;
char tempBuf[256], *varNamePtr = &tempBuf[1];
dStrcpy(tempBuf, mFileView[cell.y].text);
dStrcpy(tempBuf, mFileView[cell.y].text, 256);
//find the current mouse over char
S32 charNum = findMouseOverChar(mFileView[cell.y].text, stringPosition);
@ -526,7 +526,7 @@ void DbgFileView::onPreRender()
{
setUpdate();
char oldVar[256];
dStrcpy(oldVar, mMouseOverVariable);
dStrcpy(oldVar, mMouseOverVariable, 256);
bool found = findMouseOverVariable();
if (found && mPCCurrentLine >= 0)
{
@ -685,7 +685,7 @@ void DbgFileView::onRenderCell(Point2I offset, Point2I cell, bool selected, bool
{
S32 startPos, endPos;
char tempBuf[256];
dStrcpy(tempBuf, mFileView[cell.y].text);
dStrcpy(tempBuf, mFileView[cell.y].text, 256);
//get the end coord
tempBuf[mBlockEnd] = '\0';

View file

@ -2626,7 +2626,7 @@ DefineConsoleMethod( GuiEditCtrl, getSelectionGlobalBounds, const char*, (), , "
String str = String::ToString( "%i %i %i %i", bounds.point.x, bounds.point.y, bounds.extent.x, bounds.extent.y );
char* buffer = Con::getReturnBuffer( str.length() );
dStrcpy( buffer, str.c_str() );
dStrcpy( buffer, str.c_str(), str.length() );
return buffer;
}

View file

@ -239,7 +239,7 @@ void Filter::set(S32 argc, const char *argv[])
if (argc == 1)
{ // in the form of one string "1.0 1.0 1.0"
char list[1024];
dStrcpy(list, *argv); // strtok modifies the string so we need to copy it
dStrcpy(list, *argv, 1024); // strtok modifies the string so we need to copy it
char *value = dStrtok(list, " ");
while (value)
{