mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +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
|
|
@ -2341,7 +2341,7 @@ static int Sc_ScanString(int ret)
|
|||
return -1;
|
||||
|
||||
char* buffer = (char*)consoleAlloc(dStrlen(CMDtext));
|
||||
dStrcpy(buffer, CMDtext + 1);
|
||||
dStrcpy(buffer, CMDtext + 1, dStrlen(CMDtext));
|
||||
|
||||
CMDlval.str = MakeToken< char* >(buffer, lineIndex);
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -833,7 +833,7 @@ void SimXMLDocument::setObjectAttributes(const char* objectID)
|
|||
continue;
|
||||
|
||||
FrameTemp<char> valCopy( dStrlen( val ) + 1 );
|
||||
dStrcpy( (char *)valCopy, val );
|
||||
dStrcpy( (char *)valCopy, val, dStrlen(val) + 1 );
|
||||
|
||||
if (!pObject->writeField(itr->pFieldname, valCopy))
|
||||
continue;
|
||||
|
|
@ -873,7 +873,7 @@ void SimXMLDocument::setObjectAttributes(const char* objectID)
|
|||
// continue;
|
||||
|
||||
// FrameTemp<char> valCopy( dStrlen( val ) + 1 );
|
||||
// dStrcpy( (char *)valCopy, val );
|
||||
// dStrcpy( (char *)valCopy, val, dStrlen(val) + 1 );
|
||||
|
||||
// if (!pObject->writeField(itr->pFieldname, valCopy))
|
||||
// continue;
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ StrConstNode *StrConstNode::alloc(S32 lineNumber, char *str, bool tag, bool doc)
|
|||
ret->str = (char *)consoleAlloc(dStrlen(str) + 1);
|
||||
ret->tag = tag;
|
||||
ret->doc = doc;
|
||||
dStrcpy(ret->str, str);
|
||||
dStrcpy(ret->str, str, dStrlen(str) + 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,19 +95,17 @@ static void getFieldComponent(SimObject* object, StringTableEntry field, const c
|
|||
|
||||
// Translate xyzw and rgba into the indexed component
|
||||
// of the variable or field.
|
||||
//
|
||||
// Review: Should we use strncpy to prevent a buffer overflow?
|
||||
if (subField == xyzw[0] || subField == rgba[0])
|
||||
dStrcpy(val, StringUnit::getUnit(prevVal, 0, " \t\n"));
|
||||
dStrcpy(val, StringUnit::getUnit(prevVal, 0, " \t\n"), 128);
|
||||
|
||||
else if (subField == xyzw[1] || subField == rgba[1])
|
||||
dStrcpy(val, StringUnit::getUnit(prevVal, 1, " \t\n"));
|
||||
dStrcpy(val, StringUnit::getUnit(prevVal, 1, " \t\n"), 128);
|
||||
|
||||
else if (subField == xyzw[2] || subField == rgba[2])
|
||||
dStrcpy(val, StringUnit::getUnit(prevVal, 2, " \t\n"));
|
||||
dStrcpy(val, StringUnit::getUnit(prevVal, 2, " \t\n"), 128);
|
||||
|
||||
else if (subField == xyzw[3] || subField == rgba[3])
|
||||
dStrcpy(val, StringUnit::getUnit(prevVal, 3, " \t\n"));
|
||||
dStrcpy(val, StringUnit::getUnit(prevVal, 3, " \t\n"), 128);
|
||||
|
||||
else
|
||||
val[0] = 0;
|
||||
|
|
@ -157,19 +155,17 @@ static void setFieldComponent(SimObject* object, StringTableEntry field, const c
|
|||
|
||||
// Insert the value into the specified
|
||||
// component of the string.
|
||||
//
|
||||
// Review: Should we use strncpy to prevent a buffer overflow?
|
||||
if (subField == xyzw[0] || subField == rgba[0])
|
||||
dStrcpy(val, StringUnit::setUnit(prevVal, 0, strValue, " \t\n"));
|
||||
dStrcpy(val, StringUnit::setUnit(prevVal, 0, strValue, " \t\n"), 128);
|
||||
|
||||
else if (subField == xyzw[1] || subField == rgba[1])
|
||||
dStrcpy(val, StringUnit::setUnit(prevVal, 1, strValue, " \t\n"));
|
||||
dStrcpy(val, StringUnit::setUnit(prevVal, 1, strValue, " \t\n"), 128);
|
||||
|
||||
else if (subField == xyzw[2] || subField == rgba[2])
|
||||
dStrcpy(val, StringUnit::setUnit(prevVal, 2, strValue, " \t\n"));
|
||||
dStrcpy(val, StringUnit::setUnit(prevVal, 2, strValue, " \t\n"), 128);
|
||||
|
||||
else if (subField == xyzw[3] || subField == rgba[3])
|
||||
dStrcpy(val, StringUnit::setUnit(prevVal, 3, strValue, " \t\n"));
|
||||
dStrcpy(val, StringUnit::setUnit(prevVal, 3, strValue, " \t\n"), 128);
|
||||
|
||||
if (val[0] != 0)
|
||||
{
|
||||
|
|
@ -1729,7 +1725,7 @@ OPCodeReturn CodeInterpreter::op_setcurfield(U32 &ip)
|
|||
{
|
||||
// Save the previous field for parsing vector fields.
|
||||
mPrevField = mCurField;
|
||||
dStrcpy(prevFieldArray, curFieldArray);
|
||||
dStrcpy(prevFieldArray, curFieldArray, 256);
|
||||
mCurField = CodeToSTE(mCodeBlock->code, ip);
|
||||
curFieldArray[0] = 0;
|
||||
ip += 2;
|
||||
|
|
@ -1738,7 +1734,7 @@ OPCodeReturn CodeInterpreter::op_setcurfield(U32 &ip)
|
|||
|
||||
OPCodeReturn CodeInterpreter::op_setcurfield_array(U32 &ip)
|
||||
{
|
||||
dStrcpy(curFieldArray, STR.getStringValue());
|
||||
dStrcpy(curFieldArray, STR.getStringValue(), 256);
|
||||
return OPCodeReturn::success;
|
||||
}
|
||||
|
||||
|
|
@ -1771,7 +1767,7 @@ OPCodeReturn CodeInterpreter::op_setcurfield_this(U32 &ip)
|
|||
mCurObject = mThisObject;
|
||||
|
||||
mPrevField = mCurField;
|
||||
dStrcpy(prevFieldArray, curFieldArray);
|
||||
dStrcpy(prevFieldArray, curFieldArray, 256);
|
||||
mCurField = CodeToSTE(mCodeBlock->code, ip);
|
||||
curFieldArray[0] = 0;
|
||||
ip += 2;
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ U32 CompilerStringTable::add(const char *str, bool caseSens, bool tag)
|
|||
newStr->string = (char *)consoleAlloc(len);
|
||||
newStr->len = len;
|
||||
newStr->tag = tag;
|
||||
dStrcpy(newStr->string, str);
|
||||
dStrcpy(newStr->string, str, len);
|
||||
|
||||
// Put into the hash table.
|
||||
hashTable[str] = newStr;
|
||||
|
|
@ -195,7 +195,7 @@ char *CompilerStringTable::build()
|
|||
char *ret = new char[totalLen];
|
||||
dMemset(ret, 0, totalLen);
|
||||
for (Entry *walk = list; walk; walk = walk->next)
|
||||
dStrcpy(ret + walk->start, walk->string);
|
||||
dStrcpy(ret + walk->start, walk->string, totalLen - walk->start);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ U32 tabComplete(char* inputBuffer, U32 cursorPos, U32 maxResultLength, bool forw
|
|||
{
|
||||
// If not...
|
||||
// Save it for checking next time.
|
||||
dStrcpy(tabBuffer, inputBuffer);
|
||||
dStrcpy(tabBuffer, inputBuffer, MaxCompletionBufferSize);
|
||||
// Scan backward from the cursor position to find the base to complete from.
|
||||
S32 p = cursorPos;
|
||||
while ((p > 0) && (inputBuffer[p - 1] != ' ') && (inputBuffer[p - 1] != '.') && (inputBuffer[p - 1] != '('))
|
||||
|
|
@ -527,7 +527,7 @@ U32 tabComplete(char* inputBuffer, U32 cursorPos, U32 maxResultLength, bool forw
|
|||
}
|
||||
|
||||
// Save the modified input buffer for checking next time.
|
||||
dStrcpy(tabBuffer, inputBuffer);
|
||||
dStrcpy(tabBuffer, inputBuffer, MaxCompletionBufferSize);
|
||||
|
||||
// Return the new (maybe) cursor position.
|
||||
return cursorPos;
|
||||
|
|
@ -647,7 +647,7 @@ static void _printf(ConsoleLogEntry::Level level, ConsoleLogEntry::Type type, co
|
|||
entry.mType = type;
|
||||
#ifndef TORQUE_SHIPPING // this is equivalent to a memory leak, turn it off in ship build
|
||||
entry.mString = (const char *)consoleLogChunker.alloc(dStrlen(pos) + 1);
|
||||
dStrcpy(const_cast<char*>(entry.mString), pos);
|
||||
dStrcpy(const_cast<char*>(entry.mString), pos, dStrlen(pos) + 1);
|
||||
|
||||
// This prevents infinite recursion if the console itself needs to
|
||||
// re-allocate memory to accommodate the new console log entry, and
|
||||
|
|
@ -1271,7 +1271,7 @@ bool executeFile(const char* fileName, bool noCalls, bool journalScript)
|
|||
scriptFile = NULL;
|
||||
|
||||
dsoModifiedTime = dsoFile->getModifiedTime();
|
||||
dStrcpy(nameBuffer, scriptFileName);
|
||||
dStrcpy(nameBuffer, scriptFileName, 512);
|
||||
}
|
||||
|
||||
// If we're supposed to be compiling this file, check to see if there's a DSO
|
||||
|
|
@ -2097,12 +2097,12 @@ bool expandPath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWor
|
|||
if (ensureTrailingSlash)
|
||||
{
|
||||
// Yes, so ensure it.
|
||||
Con::ensureTrailingSlash(pDstPath, pSrcPath);
|
||||
Con::ensureTrailingSlash(pDstPath, pSrcPath, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No, so just use the source path.
|
||||
dStrcpy(pDstPath, pSrcPath);
|
||||
dStrcpy(pDstPath, pSrcPath, size);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -2118,7 +2118,7 @@ bool expandPath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWor
|
|||
if (ensureTrailingSlash)
|
||||
{
|
||||
// Yes, so ensure it.
|
||||
Con::ensureTrailingSlash(pathBuffer, pathBuffer);
|
||||
Con::ensureTrailingSlash(pathBuffer, pathBuffer, size);
|
||||
}
|
||||
|
||||
// Strip repeat slashes.
|
||||
|
|
@ -2143,12 +2143,12 @@ bool expandPath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWor
|
|||
if (ensureTrailingSlash)
|
||||
{
|
||||
// Yes, so ensure it.
|
||||
Con::ensureTrailingSlash(pDstPath, pSrcPath);
|
||||
Con::ensureTrailingSlash(pDstPath, pSrcPath, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No, so just use the source path.
|
||||
dStrcpy(pDstPath, pSrcPath);
|
||||
dStrcpy(pDstPath, pSrcPath, size);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -2183,7 +2183,7 @@ bool expandPath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWor
|
|||
if (ensureTrailingSlash)
|
||||
{
|
||||
// Yes, so ensure it.
|
||||
Con::ensureTrailingSlash(pathBuffer, pathBuffer);
|
||||
Con::ensureTrailingSlash(pathBuffer, pathBuffer, size);
|
||||
}
|
||||
|
||||
// Strip repeat slashes.
|
||||
|
|
@ -2208,7 +2208,7 @@ bool expandPath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWor
|
|||
if (ensureTrailingSlash)
|
||||
{
|
||||
// Yes, so ensure it.
|
||||
Con::ensureTrailingSlash(pathBuffer, pathBuffer);
|
||||
Con::ensureTrailingSlash(pathBuffer, pathBuffer, size);
|
||||
}
|
||||
|
||||
// Strip repeat slashes.
|
||||
|
|
@ -2300,10 +2300,10 @@ void collapsePath(char* pDstPath, U32 size, const char* pSrcPath, const char* pW
|
|||
}
|
||||
|
||||
|
||||
void ensureTrailingSlash(char* pDstPath, const char* pSrcPath)
|
||||
void ensureTrailingSlash(char* pDstPath, const char* pSrcPath, S32 dstSize)
|
||||
{
|
||||
// Copy to target.
|
||||
dStrcpy(pDstPath, pSrcPath);
|
||||
dStrcpy(pDstPath, pSrcPath, dstSize);
|
||||
|
||||
// Find trailing character index.
|
||||
S32 trailIndex = dStrlen(pDstPath);
|
||||
|
|
@ -2353,7 +2353,7 @@ StringTableEntry getDSOPath(const char *scriptPath)
|
|||
else
|
||||
{
|
||||
StringTableEntry strippedPath = Platform::stripBasePath(scriptPath);
|
||||
dStrcpy(relPath, strippedPath);
|
||||
dStrcpy(relPath, strippedPath, 1024);
|
||||
|
||||
char *slash = dStrrchr(relPath, '/');
|
||||
if (slash)
|
||||
|
|
@ -2616,7 +2616,7 @@ const char *ConsoleValue::getStringValue()
|
|||
else if(newLen > bufferLen)
|
||||
sval = (char *) dRealloc(sval, newLen);
|
||||
|
||||
dStrcpy(sval, internalValue);
|
||||
dStrcpy(sval, internalValue, newLen);
|
||||
bufferLen = newLen;
|
||||
|
||||
return sval;
|
||||
|
|
|
|||
|
|
@ -491,7 +491,7 @@ namespace Con
|
|||
bool expandPath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWorkingDirectoryHint = NULL, const bool ensureTrailingSlash = false);
|
||||
void collapsePath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWorkingDirectoryHint = NULL);
|
||||
bool isBasePath(const char* SrcPath, const char* pBasePath);
|
||||
void ensureTrailingSlash(char* pDstPath, const char* pSrcPath);
|
||||
void ensureTrailingSlash(char* pDstPath, const char* pSrcPath, S32 dstSize);
|
||||
bool stripRepeatSlashes(char* pDstPath, const char* pSrcPath, S32 dstSize);
|
||||
StringTableEntry getDSOPath(const char *scriptPath);
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ void printClassHeader(const char* usage, const char * className, const char * su
|
|||
// Copy Usage Document
|
||||
S32 usageLen = dStrlen( usage );
|
||||
FrameTemp<char> usageStr( usageLen );
|
||||
dStrcpy( usageStr, usage );
|
||||
dStrcpy( usageStr, usage, usageLen );
|
||||
|
||||
// Print Header
|
||||
Con::printf( "/*!" );
|
||||
|
|
@ -117,7 +117,7 @@ void printClassHeader(const char* usage, const char * className, const char * su
|
|||
}
|
||||
|
||||
// Copy line and update usagePtr
|
||||
dStrcpy( lineStr, usagePtr );
|
||||
dStrcpy( lineStr, usagePtr, 2048 );
|
||||
usagePtr = (newLine != NULL ) ? newLine : usagePtr;
|
||||
lineLen = dStrlen( lineStr );
|
||||
|
||||
|
|
|
|||
|
|
@ -561,12 +561,13 @@ DefineConsoleFunction( stripChars, const char*, ( const char* str, const char* c
|
|||
"@endtsexample\n"
|
||||
"@ingroup Strings" )
|
||||
{
|
||||
char* ret = Con::getReturnBuffer( dStrlen( str ) + 1 );
|
||||
dStrcpy( ret, str );
|
||||
S32 len = dStrlen(str) + 1;
|
||||
char* ret = Con::getReturnBuffer( len );
|
||||
dStrcpy( ret, str, len );
|
||||
U32 pos = dStrcspn( ret, chars );
|
||||
while ( pos < dStrlen( ret ) )
|
||||
{
|
||||
dStrcpy( ret + pos, ret + pos + 1 );
|
||||
dStrcpy( ret + pos, ret + pos + 1, len - pos );
|
||||
pos = dStrcspn( ret, chars );
|
||||
}
|
||||
return( ret );
|
||||
|
|
@ -585,7 +586,7 @@ DefineConsoleFunction( strlwr, const char*, ( const char* str ),,
|
|||
"@ingroup Strings" )
|
||||
{
|
||||
char *ret = Con::getReturnBuffer(dStrlen(str) + 1);
|
||||
dStrcpy(ret, str);
|
||||
dStrcpy(ret, str, dStrlen(str) + 1);
|
||||
return dStrlwr(ret);
|
||||
}
|
||||
|
||||
|
|
@ -602,7 +603,7 @@ DefineConsoleFunction( strupr, const char*, ( const char* str ),,
|
|||
"@ingroup Strings" )
|
||||
{
|
||||
char *ret = Con::getReturnBuffer(dStrlen(str) + 1);
|
||||
dStrcpy(ret, str);
|
||||
dStrcpy(ret, str, dStrlen(str) + 1);
|
||||
return dStrupr(ret);
|
||||
}
|
||||
|
||||
|
|
@ -663,7 +664,8 @@ DefineConsoleFunction( strreplace, const char*, ( const char* source, const char
|
|||
count++;
|
||||
}
|
||||
}
|
||||
char *ret = Con::getReturnBuffer(dStrlen(source) + 1 + (toLen - fromLen) * count);
|
||||
S32 retLen = dStrlen(source) + 1 + (toLen - fromLen) * count;
|
||||
char *ret = Con::getReturnBuffer(retLen);
|
||||
U32 scanp = 0;
|
||||
U32 dstp = 0;
|
||||
for(;;)
|
||||
|
|
@ -671,13 +673,13 @@ DefineConsoleFunction( strreplace, const char*, ( const char* source, const char
|
|||
const char *scan = dStrstr(source + scanp, from);
|
||||
if(!scan)
|
||||
{
|
||||
dStrcpy(ret + dstp, source + scanp);
|
||||
dStrcpy(ret + dstp, source + scanp, retLen - dstp);
|
||||
return ret;
|
||||
}
|
||||
U32 len = scan - (source + scanp);
|
||||
dStrncpy(ret + dstp, source + scanp, len);
|
||||
dStrncpy(ret + dstp, source + scanp, getMin(len, retLen - dstp));
|
||||
dstp += len;
|
||||
dStrcpy(ret + dstp, to);
|
||||
dStrcpy(ret + dstp, to, retLen - dstp);
|
||||
dstp += toLen;
|
||||
scanp += len + fromLen;
|
||||
}
|
||||
|
|
@ -901,8 +903,8 @@ DefineConsoleFunction( startsWith, bool, ( const char* str, const char* prefix,
|
|||
char* targetBuf = new char[ targetLen + 1 ];
|
||||
|
||||
// copy src and target into buffers
|
||||
dStrcpy( srcBuf, str );
|
||||
dStrcpy( targetBuf, prefix );
|
||||
dStrcpy( srcBuf, str, srcLen + 1 );
|
||||
dStrcpy( targetBuf, prefix, targetLen + 1 );
|
||||
|
||||
// reassign src/target pointers to lowercase versions
|
||||
str = dStrlwr( srcBuf );
|
||||
|
|
@ -952,8 +954,8 @@ DefineConsoleFunction( endsWith, bool, ( const char* str, const char* suffix, bo
|
|||
char* targetBuf = new char[ targetLen + 1 ];
|
||||
|
||||
// copy src and target into buffers
|
||||
dStrcpy( srcBuf, str );
|
||||
dStrcpy( targetBuf, suffix );
|
||||
dStrcpy( srcBuf, str, srcLen + 1 );
|
||||
dStrcpy( targetBuf, suffix, targetLen + 1 );
|
||||
|
||||
// reassign src/target pointers to lowercase versions
|
||||
str = dStrlwr( srcBuf );
|
||||
|
|
@ -1825,7 +1827,7 @@ DefineEngineFunction( detag, const char*, ( const char* str ),,
|
|||
return "";
|
||||
|
||||
char* ret = Con::getReturnBuffer( dStrlen( word + 1 ) + 1 );
|
||||
dStrcpy( ret, word + 1 );
|
||||
dStrcpy( ret, word + 1, dStrlen(word + 1) + 1 );
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
|
|
@ -1889,7 +1891,7 @@ ConsoleFunction( echo, void, 2, 0, "( string message... ) "
|
|||
char *ret = Con::getReturnBuffer(len + 1);
|
||||
ret[0] = 0;
|
||||
for(i = 1; i < argc; i++)
|
||||
dStrcat(ret, argv[i], len);
|
||||
dStrcat(ret, argv[i], len + 1);
|
||||
|
||||
Con::printf("%s", ret);
|
||||
ret[0] = 0;
|
||||
|
|
@ -1913,7 +1915,7 @@ ConsoleFunction( warn, void, 2, 0, "( string message... ) "
|
|||
char *ret = Con::getReturnBuffer(len + 1);
|
||||
ret[0] = 0;
|
||||
for(i = 1; i < argc; i++)
|
||||
dStrcat(ret, argv[i], len);
|
||||
dStrcat(ret, argv[i], len + 1);
|
||||
|
||||
Con::warnf(ConsoleLogEntry::General, "%s", ret);
|
||||
ret[0] = 0;
|
||||
|
|
@ -1937,7 +1939,7 @@ ConsoleFunction( error, void, 2, 0, "( string message... ) "
|
|||
char *ret = Con::getReturnBuffer(len + 1);
|
||||
ret[0] = 0;
|
||||
for(i = 1; i < argc; i++)
|
||||
dStrcat(ret, argv[i], len);
|
||||
dStrcat(ret, argv[i], len + 1);
|
||||
|
||||
Con::errorf(ConsoleLogEntry::General, "%s", ret);
|
||||
ret[0] = 0;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ StringValue & StringValue::operator=(const char *string)
|
|||
{
|
||||
S32 len = dStrlen(string);
|
||||
if (len < size)
|
||||
dStrcpy(val, string);
|
||||
dStrcpy(val, string, size);
|
||||
else
|
||||
{
|
||||
size = len;
|
||||
|
|
@ -569,7 +569,7 @@ void ConsoleValue::setStringValue(const char * value)
|
|||
type = TypeInternalString;
|
||||
|
||||
bufferLen = newLen;
|
||||
dStrcpy(sval, value);
|
||||
dStrcpy(sval, value, newLen);
|
||||
}
|
||||
else
|
||||
Con::setData(type, dataPtr, 0, 1, &value, enumTable);
|
||||
|
|
@ -702,7 +702,7 @@ Dictionary::Entry* Dictionary::addVariable(const char *name,
|
|||
if (name[0] != '$')
|
||||
{
|
||||
scratchBuffer[0] = '$';
|
||||
dStrcpy(scratchBuffer + 1, name);
|
||||
dStrcpy(scratchBuffer + 1, name, 1023);
|
||||
name = scratchBuffer;
|
||||
}
|
||||
|
||||
|
|
@ -1360,7 +1360,7 @@ void Namespace::addScriptCallback(const char *funcName, const char *usage, Conso
|
|||
static U32 uid = 0;
|
||||
char buffer[1024];
|
||||
char lilBuffer[32];
|
||||
dStrcpy(buffer, funcName);
|
||||
dStrcpy(buffer, funcName, 1024);
|
||||
dSprintf(lilBuffer, 32, "_%d_cb", uid++);
|
||||
dStrcat(buffer, lilBuffer, 1024);
|
||||
|
||||
|
|
@ -1381,7 +1381,7 @@ void Namespace::markGroup(const char* name, const char* usage)
|
|||
static U32 uid = 0;
|
||||
char buffer[1024];
|
||||
char lilBuffer[32];
|
||||
dStrcpy(buffer, name);
|
||||
dStrcpy(buffer, name, 1024);
|
||||
dSprintf(lilBuffer, 32, "_%d", uid++);
|
||||
dStrcat(buffer, lilBuffer, 1024);
|
||||
|
||||
|
|
|
|||
|
|
@ -773,7 +773,7 @@ static const char* returnClassList( Vector< AbstractClassRep* >& classes, U32 bu
|
|||
dQsort( classes.address(), classes.size(), sizeof( AbstractClassRep* ), ACRCompare );
|
||||
|
||||
char* ret = Con::getReturnBuffer( bufSize );
|
||||
dStrcpy( ret, classes[ 0 ]->getClassName() );
|
||||
dStrcpy( ret, classes[ 0 ]->getClassName(), bufSize );
|
||||
for( U32 i = 1; i < classes.size(); i ++ )
|
||||
{
|
||||
dStrcat( ret, "\t", bufSize );
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ DefineConsoleMethod(FieldBrushObject, queryFields, const char*, (const char* sim
|
|||
for ( U32 groupIndex = 0; groupIndex < groupCount; ++groupIndex )
|
||||
{
|
||||
// Copy string element.
|
||||
dStrcpy( tempBuf, StringUnit::getUnit( groupList, groupIndex, " \t\n" ) );
|
||||
dStrcpy( tempBuf, StringUnit::getUnit( groupList, groupIndex, " \t\n" ), 256 );
|
||||
// Append internal name.
|
||||
dStrcat( tempBuf, "_begingroup", 256 );
|
||||
// Store Group.
|
||||
|
|
@ -416,7 +416,7 @@ void FieldBrushObject::copyFields( SimObject* pSimObject, const char* fieldList
|
|||
for ( U32 fieldIndex = 0; fieldIndex < fieldCount; ++fieldIndex )
|
||||
{
|
||||
// Copy string element.
|
||||
dStrcpy( tempBuf, StringUnit::getUnit( fieldList, fieldIndex, " \t\n" ) );
|
||||
dStrcpy( tempBuf, StringUnit::getUnit( fieldList, fieldIndex, " \t\n" ), bufferSizes );
|
||||
|
||||
// Store field.
|
||||
fields.push_back( StringTable->insert( tempBuf ) );
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ DefineEngineFunction(getDirectoryList, String, ( const char* path, S32 depth ),
|
|||
// Copy the directory names to the buffer.
|
||||
for (S32 i = 0; i < directories.size(); i++)
|
||||
{
|
||||
dStrcpy(p, directories[i]);
|
||||
dStrcpy(p, directories[i], length - (p - buffer));
|
||||
p += dStrlen(directories[i]);
|
||||
// Tab separated.
|
||||
p[0] = '\t';
|
||||
|
|
@ -537,7 +537,7 @@ DefineEngineFunction( fileModifiedTime, String, ( const char* fileName ),,
|
|||
String fileStr = Platform::localTimeToString( lt );
|
||||
|
||||
char *buffer = Con::getReturnBuffer( fileStr.size() );
|
||||
dStrcpy( buffer, fileStr );
|
||||
dStrcpy( buffer, fileStr, fileStr.size() );
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
|
@ -560,7 +560,7 @@ DefineEngineFunction( fileCreatedTime, String, ( const char* fileName ),,
|
|||
String fileStr = Platform::localTimeToString( lt );
|
||||
|
||||
char *buffer = Con::getReturnBuffer( fileStr.size() );
|
||||
dStrcpy( buffer, fileStr );
|
||||
dStrcpy( buffer, fileStr, fileStr.size() );
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
|
@ -609,7 +609,7 @@ DefineEngineFunction(fileBase, String, ( const char* fileName ),,
|
|||
S32 pathLen = dStrlen( fileName );
|
||||
FrameTemp<char> szPathCopy( pathLen + 1);
|
||||
|
||||
dStrcpy( szPathCopy, fileName );
|
||||
dStrcpy( szPathCopy, fileName, pathLen + 1 );
|
||||
forwardslash( szPathCopy );
|
||||
|
||||
const char *path = dStrrchr(szPathCopy, '/');
|
||||
|
|
@ -618,7 +618,7 @@ DefineEngineFunction(fileBase, String, ( const char* fileName ),,
|
|||
else
|
||||
path++;
|
||||
char *ret = Con::getReturnBuffer(dStrlen(path) + 1);
|
||||
dStrcpy(ret, path);
|
||||
dStrcpy(ret, path, dStrlen(path) + 1);
|
||||
char *ext = dStrrchr(ret, '.');
|
||||
if(ext)
|
||||
*ext = 0;
|
||||
|
|
@ -635,7 +635,7 @@ DefineEngineFunction(fileName, String, ( const char* fileName ),,
|
|||
S32 pathLen = dStrlen( fileName );
|
||||
FrameTemp<char> szPathCopy( pathLen + 1);
|
||||
|
||||
dStrcpy( szPathCopy, fileName );
|
||||
dStrcpy( szPathCopy, fileName, pathLen + 1 );
|
||||
forwardslash( szPathCopy );
|
||||
|
||||
const char *name = dStrrchr(szPathCopy, '/');
|
||||
|
|
@ -644,7 +644,7 @@ DefineEngineFunction(fileName, String, ( const char* fileName ),,
|
|||
else
|
||||
name++;
|
||||
char *ret = Con::getReturnBuffer(dStrlen(name));
|
||||
dStrcpy(ret, name);
|
||||
dStrcpy(ret, name, dStrlen(name));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -658,7 +658,7 @@ DefineEngineFunction(filePath, String, ( const char* fileName ),,
|
|||
S32 pathLen = dStrlen( fileName );
|
||||
FrameTemp<char> szPathCopy( pathLen + 1);
|
||||
|
||||
dStrcpy( szPathCopy, fileName );
|
||||
dStrcpy( szPathCopy, fileName, pathLen + 1 );
|
||||
forwardslash( szPathCopy );
|
||||
|
||||
const char *path = dStrrchr(szPathCopy, '/');
|
||||
|
|
|
|||
|
|
@ -950,7 +950,7 @@ void PersistenceManager::updateToken( const U32 lineNumber, const U32 linePositi
|
|||
char* postString = ( char* ) dMalloc( postStringLen + 1 );
|
||||
if( needQuotes )
|
||||
postString[ 0 ] = '"';
|
||||
dStrcpy( &postString[ needQuotes ? 1 : 0 ], postStringSrc );
|
||||
dStrcpy( &postString[ needQuotes ? 1 : 0 ], postStringSrc, postStringLen + (needQuotes ? 0 : 1) );
|
||||
postString[ postStringLen ] = 0;
|
||||
|
||||
// Calculate the length of our new line
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ bool expandToolScriptFilename(char *filename, U32 size, const char *src)
|
|||
// Relative to script directory
|
||||
if(cbFullPath)
|
||||
{
|
||||
dStrcpy(varBuf, cbFullPath);
|
||||
dStrcpy(varBuf, cbFullPath, 1024);
|
||||
slash = dStrrchr(varBuf, '/');
|
||||
if(slash) *slash = 0;
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ bool expandOldScriptFilename(char *filename, U32 size, const char *src)
|
|||
const StringTableEntry cbName = CodeBlock::getCurrentCodeBlockName();
|
||||
if (!cbName)
|
||||
{
|
||||
dStrcpy(filename, src);
|
||||
dStrcpy(filename, src, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ bool expandOldScriptFilename(char *filename, U32 size, const char *src)
|
|||
*filename = 0;
|
||||
return false;
|
||||
}
|
||||
dStrcpy(filename, src);
|
||||
dStrcpy(filename, src, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ bool expandOldScriptFilename(char *filename, U32 size, const char *src)
|
|||
}
|
||||
|
||||
dStrncpy(filename, cbName, length);
|
||||
dStrcpy(filename+length, src+1);
|
||||
dStrcpy(filename+length, src+1, size - length);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ DefineConsoleFunction( getUniqueName, const char*, (const char * baseName), ,
|
|||
return NULL;
|
||||
|
||||
char *buffer = Con::getReturnBuffer( outName.size() );
|
||||
dStrcpy( buffer, outName );
|
||||
dStrcpy( buffer, outName, outName.size() );
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ DefineConsoleFunction( getUniqueInternalName, const char*, (const char * baseNam
|
|||
return NULL;
|
||||
|
||||
char *buffer = Con::getReturnBuffer( outName.size() );
|
||||
dStrcpy( buffer, outName );
|
||||
dStrcpy( buffer, outName, outName.size() );
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,10 +198,10 @@ void SimDataBlock::performSubstitutions(SimDataBlock* dblock, const SimObject* o
|
|||
}
|
||||
|
||||
char obj_str[32];
|
||||
dStrcpy(obj_str, Con::getIntArg(obj->getId()));
|
||||
dStrcpy(obj_str, Con::getIntArg(obj->getId()), 32);
|
||||
|
||||
char index_str[32];
|
||||
dStrcpy(index_str, Con::getIntArg(index));
|
||||
dStrcpy(index_str, Con::getIntArg(index), 32);
|
||||
|
||||
for (S32 i = 0; i < substitutions.size(); i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ void SimObject::writeFields(Stream &stream, U32 tabStop)
|
|||
|
||||
U32 nBufferSize = dStrlen( val ) + 1;
|
||||
FrameTemp<char> valCopy( nBufferSize );
|
||||
dStrcpy( (char *)valCopy, val );
|
||||
dStrcpy( (char *)valCopy, val, nBufferSize );
|
||||
|
||||
if (!writeField(f->pFieldname, valCopy))
|
||||
continue;
|
||||
|
|
@ -402,12 +402,12 @@ bool SimObject::save(const char *pcFileName, bool bOnlySelected, const char *pre
|
|||
char docRoot[256];
|
||||
char modRoot[256];
|
||||
|
||||
dStrcpy(docRoot, pcFileName);
|
||||
dStrcpy(docRoot, pcFileName, 256);
|
||||
char *p = dStrrchr(docRoot, '/');
|
||||
if (p) *++p = '\0';
|
||||
else docRoot[0] = '\0';
|
||||
|
||||
dStrcpy(modRoot, pcFileName);
|
||||
dStrcpy(modRoot, pcFileName, 256);
|
||||
p = dStrchr(modRoot, '/');
|
||||
if (p) *++p = '\0';
|
||||
else modRoot[0] = '\0';
|
||||
|
|
@ -1028,7 +1028,7 @@ void SimObject::setDataField(StringTableEntry slotName, const char *array, const
|
|||
else
|
||||
{
|
||||
char buf[256];
|
||||
dStrcpy(buf, slotName);
|
||||
dStrcpy(buf, slotName, 256);
|
||||
dStrcat(buf, array, 256);
|
||||
StringTableEntry permanentSlotName = StringTable->insert(buf);
|
||||
mFieldDictionary->setFieldValue(permanentSlotName, value);
|
||||
|
|
@ -1069,7 +1069,7 @@ const char *SimObject::getDataField(StringTableEntry slotName, const char *array
|
|||
else
|
||||
{
|
||||
static char buf[256];
|
||||
dStrcpy(buf, slotName);
|
||||
dStrcpy(buf, slotName, 256);
|
||||
dStrcat(buf, array, 256);
|
||||
if (const char* val = mFieldDictionary->getFieldValue(StringTable->insert(buf)))
|
||||
return val;
|
||||
|
|
@ -1310,7 +1310,7 @@ U32 SimObject::getDataFieldType( StringTableEntry slotName, const char* array )
|
|||
else
|
||||
{
|
||||
static char buf[256];
|
||||
dStrcpy( buf, slotName );
|
||||
dStrcpy( buf, slotName, 256 );
|
||||
dStrcat( buf, array, 256 );
|
||||
|
||||
return mFieldDictionary->getFieldType( StringTable->insert( buf ) );
|
||||
|
|
@ -1333,7 +1333,7 @@ void SimObject::setDataFieldType(const U32 fieldTypeId, StringTableEntry slotNam
|
|||
else
|
||||
{
|
||||
static char buf[256];
|
||||
dStrcpy( buf, slotName );
|
||||
dStrcpy( buf, slotName, 256 );
|
||||
dStrcat( buf, array, 256 );
|
||||
|
||||
mFieldDictionary->setFieldType( StringTable->insert( buf ), fieldTypeId );
|
||||
|
|
@ -1354,7 +1354,7 @@ void SimObject::setDataFieldType(const char *typeName, StringTableEntry slotName
|
|||
else
|
||||
{
|
||||
static char buf[256];
|
||||
dStrcpy( buf, slotName );
|
||||
dStrcpy( buf, slotName, 256 );
|
||||
dStrcat( buf, array, 256 );
|
||||
StringTableEntry permanentSlotName = StringTable->insert(buf);
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ SimObject *SimObjectMemento::restore() const
|
|||
tempBuffer = ( char* ) dMalloc( dStrlen( mState ) + uniqueNameLen + 1 );
|
||||
dMemcpy( tempBuffer, mState, numCharsToLeftParen );
|
||||
dMemcpy( &tempBuffer[ numCharsToLeftParen ], uniqueName, uniqueNameLen );
|
||||
dStrcpy( &tempBuffer[ numCharsToLeftParen + uniqueNameLen ], &mState[ numCharsToLeftParen ] );
|
||||
dStrcpy( &tempBuffer[ numCharsToLeftParen + uniqueNameLen ], &mState[ numCharsToLeftParen ], dStrlen(mState) - numCharsToLeftParen + 1 );
|
||||
}
|
||||
|
||||
Con::evaluate( tempBuffer );
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ struct StringStack
|
|||
mLen = dStrlen(s);
|
||||
|
||||
validateBufferSize(mStart + mLen + 2);
|
||||
dStrcpy(mBuffer + mStart, s);
|
||||
dStrcpy(mBuffer + mStart, s, mBufferSize - mStart);
|
||||
}
|
||||
|
||||
/// Get the top of the stack, as a StringTableEntry.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue