From 963333c583c01ababc9d6f7e490e1f2667dd90cb Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Wed, 7 Mar 2018 01:13:56 -0500 Subject: [PATCH] More cats and cpys in files that xcode doesn't see --- Engine/source/afx/ce/afxAudioBank.cpp | 2 +- Engine/source/console/CMDscan.l | 8 ++++---- Engine/source/console/consoleXMLExport.cpp | 4 ++-- Engine/source/core/frameAllocator.h | 2 +- Engine/source/core/util/zip/test/zipTestWrite.cpp | 4 ++-- Engine/source/gui/controls/guiPopUpCtrlEx.cpp | 12 ++++++------ .../platform/input/leapMotion/leapMotionDevice.cpp | 2 +- .../platform/input/oculusVR/oculusVRDevice.cpp | 2 +- .../source/platform/input/openVR/openVRProvider.cpp | 2 +- .../platform/input/razerHydra/razerHydraDevice.cpp | 2 +- Engine/source/platformX86UNIX/x86UNIXFileio.cpp | 10 +++++----- .../source/platformX86UNIX/x86UNIXInput.client.cpp | 2 +- Engine/source/platformX86UNIX/x86UNIXNet.cpp | 6 +++--- .../platformX86UNIX/x86UNIXOGLVideo.client.cpp | 2 +- Engine/source/platformX86UNIX/x86UNIXRedbook.cpp | 2 +- Engine/source/shaderGen/HLSL/shaderCompHLSL.cpp | 2 +- Engine/source/sim/actionMap.cpp | 2 +- Engine/source/sim/connectionStringTable.cpp | 2 +- Engine/source/sim/netObject.h | 8 ++++---- Engine/source/sqlite/SQLiteObject.cpp | 6 +++--- Engine/source/testing/unitTesting.cpp | 4 ++-- 21 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Engine/source/afx/ce/afxAudioBank.cpp b/Engine/source/afx/ce/afxAudioBank.cpp index 2aa148474..82537419d 100644 --- a/Engine/source/afx/ce/afxAudioBank.cpp +++ b/Engine/source/afx/ce/afxAudioBank.cpp @@ -184,7 +184,7 @@ void afxAudioBank::packData(BitStream* stream) if(!mFilename) buffer[0] = 0; else - dStrcpy(buffer, mFilename); + dStrcpy(buffer, mFilename, 256); stream->writeString(buffer); */ diff --git a/Engine/source/console/CMDscan.l b/Engine/source/console/CMDscan.l index d9b92b6d2..c4bdc1bf3 100644 --- a/Engine/source/console/CMDscan.l +++ b/Engine/source/console/CMDscan.l @@ -71,7 +71,7 @@ inline int isatty(int) { return 0; } buf[n++] = (char) c; \ result = n; \ } - + // General helper stuff. static int lineIndex; @@ -411,10 +411,10 @@ static int Sc_ScanString(int ret) CMDtext[CMDleng - 1] = 0; if(!collapseEscape(CMDtext+1)) 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; } diff --git a/Engine/source/console/consoleXMLExport.cpp b/Engine/source/console/consoleXMLExport.cpp index 953a016cf..79e302595 100644 --- a/Engine/source/console/consoleXMLExport.cpp +++ b/Engine/source/console/consoleXMLExport.cpp @@ -319,8 +319,8 @@ DefineConsoleFunction( consoleExportXML, const char*, (), ,"Exports console defi Con::XMLExport xmlExport; String xml; xmlExport.exportXML(xml); - char* ret = Con::getReturnBuffer(xml.length() + 1); - dStrcpy(ret, xml.c_str()); + char* ret = Con::getReturnBuffer(xml.size()); + dStrcpy(ret, xml.c_str(), xml.size()); return ret; } diff --git a/Engine/source/core/frameAllocator.h b/Engine/source/core/frameAllocator.h index 86884085c..2e03e6fc2 100644 --- a/Engine/source/core/frameAllocator.h +++ b/Engine/source/core/frameAllocator.h @@ -185,7 +185,7 @@ public: /// the FrameAllocator. For example: /// @code /// FrameTemp tempStr(32); // NOTE! This parameter is NOT THE SIZE IN BYTES. See constructor docs. -/// dStrcat( tempStr, SomeOtherString ); +/// dStrcat( tempStr, SomeOtherString, 32 * sizeof(char) ); /// tempStr[2] = 'l'; /// Con::printf( tempStr ); /// Con::printf( "Foo: %s", ~tempStr ); diff --git a/Engine/source/core/util/zip/test/zipTestWrite.cpp b/Engine/source/core/util/zip/test/zipTestWrite.cpp index 889cf6948..d23f9a657 100644 --- a/Engine/source/core/util/zip/test/zipTestWrite.cpp +++ b/Engine/source/core/util/zip/test/zipTestWrite.cpp @@ -95,7 +95,7 @@ private: { // Find a unique filename U32 count = 1; - dStrcpy(fileBuf, filename); + dStrcpy(fileBuf, filename, bufSize); while(zip->findFileInfo(fileBuf)) { @@ -109,7 +109,7 @@ private: } } else if(fileBuf && bufSize > 0) - dStrcpy(fileBuf, filename); + dStrcpy(fileBuf, filename, bufSize); // Try and write to the file Stream * stream = zip->openFile(fileBuf ? fileBuf : filename, ZipArchive::Write); diff --git a/Engine/source/gui/controls/guiPopUpCtrlEx.cpp b/Engine/source/gui/controls/guiPopUpCtrlEx.cpp index fc7811e69..2c8f5342a 100644 --- a/Engine/source/gui/controls/guiPopUpCtrlEx.cpp +++ b/Engine/source/gui/controls/guiPopUpCtrlEx.cpp @@ -390,7 +390,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol U32 r, g, b; char buf[64]; - dStrcpy( buf, argv[3] ); + dStrcpy( buf, argv[3], 64 ); char* temp = dStrtok( buf, " \0" ); r = temp ? dAtoi( temp ) : 0; temp = dStrtok( NULL, " \0" ); @@ -399,7 +399,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol b = temp ? dAtoi( temp ) : 0; fontColor.set( r, g, b ); - dStrcpy( buf, argv[4] ); + dStrcpy( buf, argv[4], 64 ); temp = dStrtok( buf, " \0" ); r = temp ? dAtoi( temp ) : 0; temp = dStrtok( NULL, " \0" ); @@ -408,7 +408,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol b = temp ? dAtoi( temp ) : 0; fontColorHL.set( r, g, b ); - dStrcpy( buf, argv[5] ); + dStrcpy( buf, argv[5], 64 ); temp = dStrtok( buf, " \0" ); r = temp ? dAtoi( temp ) : 0; temp = dStrtok( NULL, " \0" ); @@ -426,7 +426,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol // U32 r, g, b; // char buf[64]; // -// dStrcpy( buf, argv[3] ); +// dStrcpy( buf, argv[3], 64 ); // char* temp = dStrtok( buf, " \0" ); // r = temp ? dAtoi( temp ) : 0; // temp = dStrtok( NULL, " \0" ); @@ -435,7 +435,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol // b = temp ? dAtoi( temp ) : 0; // fontColor.set( r, g, b ); // -// dStrcpy( buf, argv[4] ); +// dStrcpy( buf, argv[4], 64 ); // temp = dStrtok( buf, " \0" ); // r = temp ? dAtoi( temp ) : 0; // temp = dStrtok( NULL, " \0" ); @@ -444,7 +444,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol // b = temp ? dAtoi( temp ) : 0; // fontColorHL.set( r, g, b ); // -// dStrcpy( buf, argv[5] ); +// dStrcpy( buf, argv[5], 64 ); // temp = dStrtok( buf, " \0" ); // r = temp ? dAtoi( temp ) : 0; // temp = dStrtok( NULL, " \0" ); diff --git a/Engine/source/platform/input/leapMotion/leapMotionDevice.cpp b/Engine/source/platform/input/leapMotion/leapMotionDevice.cpp index 5e4aef681..9bbb3eaaf 100644 --- a/Engine/source/platform/input/leapMotion/leapMotionDevice.cpp +++ b/Engine/source/platform/input/leapMotion/leapMotionDevice.cpp @@ -82,7 +82,7 @@ U32 LeapMotionDevice::LM_FRAME = 0; LeapMotionDevice::LeapMotionDevice() { // From IInputDevice - dStrcpy(mName, "leapmotion"); + dStrcpy(mName, "leapmotion", 30); mDeviceType = INPUTMGR->getNextDeviceType(); mController = NULL; diff --git a/Engine/source/platform/input/oculusVR/oculusVRDevice.cpp b/Engine/source/platform/input/oculusVR/oculusVRDevice.cpp index 229bc0429..e2ffb411a 100644 --- a/Engine/source/platform/input/oculusVR/oculusVRDevice.cpp +++ b/Engine/source/platform/input/oculusVR/oculusVRDevice.cpp @@ -86,7 +86,7 @@ F32 OculusVRDevice::smPositionTrackingScale = 1.0f; OculusVRDevice::OculusVRDevice() { // From IInputDevice - dStrcpy(mName, "oculusvr"); + dStrcpy(mName, "oculusvr", 30); mDeviceType = INPUTMGR->getNextDeviceType(); // diff --git a/Engine/source/platform/input/openVR/openVRProvider.cpp b/Engine/source/platform/input/openVR/openVRProvider.cpp index 9fa31e4cc..53cc228f5 100644 --- a/Engine/source/platform/input/openVR/openVRProvider.cpp +++ b/Engine/source/platform/input/openVR/openVRProvider.cpp @@ -493,7 +493,7 @@ OpenVRProvider::OpenVRProvider() : mDrawCanvas(NULL), mGameConnection(NULL) { - dStrcpy(mName, "openvr"); + dStrcpy(mName, "openvr", 30); mDeviceType = INPUTMGR->getNextDeviceType(); buildInputCodeTable(); GFXDevice::getDeviceEventSignal().notify(this, &OpenVRProvider::_handleDeviceEvent); diff --git a/Engine/source/platform/input/razerHydra/razerHydraDevice.cpp b/Engine/source/platform/input/razerHydra/razerHydraDevice.cpp index 8a36bd9d6..e2d87129d 100644 --- a/Engine/source/platform/input/razerHydra/razerHydraDevice.cpp +++ b/Engine/source/platform/input/razerHydra/razerHydraDevice.cpp @@ -91,7 +91,7 @@ U32 RazerHydraDevice::RH_FRAME = 0; RazerHydraDevice::RazerHydraDevice() { // From IInputDevice - dStrcpy(mName, "razerhydra"); + dStrcpy(mName, "razerhydra", 30); mDeviceType = INPUTMGR->getNextDeviceType(); // diff --git a/Engine/source/platformX86UNIX/x86UNIXFileio.cpp b/Engine/source/platformX86UNIX/x86UNIXFileio.cpp index 6e51b85e1..40f5fedae 100644 --- a/Engine/source/platformX86UNIX/x86UNIXFileio.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXFileio.cpp @@ -211,7 +211,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite) dStrncpy(pathEl, currChar, pathElLen); pathEl[pathElLen] = '\0'; dStrncpy(testPath, tempBuf, MaxPath); - dStrcat(testPath, pathEl); + dStrcat(testPath, pathEl, MaxPath); if (stat(testPath, &filestat) != -1) { dStrncpy(tempBuf, testPath, MaxPath); @@ -226,7 +226,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite) if (dStricmp(pathEl, ent->d_name) == 0) { foundMatch = true; - dStrcat(tempBuf, ent->d_name); + dStrcat(tempBuf, ent->d_name, MaxPath); break; } } @@ -238,7 +238,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite) } if (*termChar == '/') { - dStrcat(tempBuf, "/"); + dStrcat(tempBuf, "/", MaxPath); termChar++; currChar = termChar; } @@ -935,7 +935,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite) TempAlloc< UTF8 > buf( dStrlen( newDir ) + 2 ); - dStrcpy( buf, newDir ); + dStrcpy( buf, newDir, buf.size ); ForwardSlash( buf ); return chdir( buf ) == 0; @@ -1267,7 +1267,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite) { char child[1024]; if ( (basePath[dStrlen(basePath) - 1]) == '/') - dStrcpy (child, d->d_name); + dStrcpy (child, d->d_name, 1024); else dSprintf(child, 1024, "/%s", d->d_name); if (currentDepth < recurseDepth || recurseDepth == -1) diff --git a/Engine/source/platformX86UNIX/x86UNIXInput.client.cpp b/Engine/source/platformX86UNIX/x86UNIXInput.client.cpp index 37e3ee179..2776601a7 100644 --- a/Engine/source/platformX86UNIX/x86UNIXInput.client.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXInput.client.cpp @@ -554,7 +554,7 @@ bool XClipboard::setClipboard(const char *text) checkTDataSize(len); // copy the data into the storage buffer - dStrcpy(mTData, text); + dStrcpy(mTData, text, mTDataSize); // tell X that we own the clipboard. (we'll get events // if an app tries to paste) diff --git a/Engine/source/platformX86UNIX/x86UNIXNet.cpp b/Engine/source/platformX86UNIX/x86UNIXNet.cpp index e186b8f8a..2cfb81521 100644 --- a/Engine/source/platformX86UNIX/x86UNIXNet.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXNet.cpp @@ -97,7 +97,7 @@ static Socket* addPolledSocket(NetSocket& fd, S32 state, sock->fd = fd; sock->state = state; if (remoteAddr) - dStrcpy(sock->remoteAddr, remoteAddr); + dStrcpy(sock->remoteAddr, remoteAddr, 256); if (port != -1) sock->remotePort = port; gPolledSockets.push_back(sock); @@ -242,7 +242,7 @@ NetSocket Net::openConnectTo(const char *addressString) if(!dStrnicmp(addressString, "ip:", 3)) addressString += 3; // eat off the ip: char remoteAddr[256]; - dStrcpy(remoteAddr, addressString); + dStrcpy(remoteAddr, addressString, 256); char *portString = dStrchr(remoteAddr, ':'); @@ -814,7 +814,7 @@ bool Net::stringToAddress(const char *addressString, NetAddress *address) if(strlen(addressString) > 255) return false; - dStrcpy(remoteAddr, addressString); + dStrcpy(remoteAddr, addressString, 256); char *portString = dStrchr(remoteAddr, ':'); if(portString) diff --git a/Engine/source/platformX86UNIX/x86UNIXOGLVideo.client.cpp b/Engine/source/platformX86UNIX/x86UNIXOGLVideo.client.cpp index 16f906f69..384aade9e 100644 --- a/Engine/source/platformX86UNIX/x86UNIXOGLVideo.client.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXOGLVideo.client.cpp @@ -41,7 +41,7 @@ bool InitOpenGL() // Get the video settings from the prefs: const char* resString = Con::getVariable( "$pref::Video::resolution" ); char* tempBuf = new char[dStrlen( resString ) + 1]; - dStrcpy( tempBuf, resString ); + dStrcpy( tempBuf, resString, dStrlen(resString) + 1 ); char* temp = dStrtok( tempBuf, " x\0" ); U32 width = ( temp ? dAtoi( temp ) : 800 ); temp = dStrtok( NULL, " x\0" ); diff --git a/Engine/source/platformX86UNIX/x86UNIXRedbook.cpp b/Engine/source/platformX86UNIX/x86UNIXRedbook.cpp index 65741218f..3484a56ce 100644 --- a/Engine/source/platformX86UNIX/x86UNIXRedbook.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXRedbook.cpp @@ -102,7 +102,7 @@ void UnixRedBookDevice::setDeviceInfo(S32 deviceId, const char *deviceName) #if !defined(__FreeBSD__) mDeviceId = deviceId; mDeviceName = new char[dStrlen(deviceName) + 1]; - dStrcpy(mDeviceName, deviceName); + dStrcpy(mDeviceName, deviceName, dStrlen(deviceName) + 1); #endif // !defined(__FreeBSD__) } diff --git a/Engine/source/shaderGen/HLSL/shaderCompHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderCompHLSL.cpp index b01419a8b..66c23d353 100644 --- a/Engine/source/shaderGen/HLSL/shaderCompHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderCompHLSL.cpp @@ -232,7 +232,7 @@ void ShaderConnectorHLSL::sortVars() void ShaderConnectorHLSL::setName( char *newName ) { - dStrcpy( (char*)mName, newName ); + dStrcpy( (char*)mName, newName, 32 ); } void ShaderConnectorHLSL::reset() diff --git a/Engine/source/sim/actionMap.cpp b/Engine/source/sim/actionMap.cpp index 948d066c1..1d0fbe8b5 100644 --- a/Engine/source/sim/actionMap.cpp +++ b/Engine/source/sim/actionMap.cpp @@ -1159,7 +1159,7 @@ bool ActionMap::getKeyString(const U32 action, char* buffer) } //for (U32 i = 0; gVirtualMap[i].code != 0xFFFFFFFF; i++) { // if (gVirtualMap[i].code == action) { - // dStrcpy(buffer, gVirtualMap[i].pDescription); + // dStrcpy(buffer, gVirtualMap[i].pDescription, 16); // return true; // } //} diff --git a/Engine/source/sim/connectionStringTable.cpp b/Engine/source/sim/connectionStringTable.cpp index dddd935b2..c3fa4dff6 100644 --- a/Engine/source/sim/connectionStringTable.cpp +++ b/Engine/source/sim/connectionStringTable.cpp @@ -71,7 +71,7 @@ public: static char buffer[512]; dSprintf(buffer, sizeof(buffer), "%s - \"", getClassName()); expandEscape(buffer + dStrlen(buffer), mString.getString()); - dStrcat(buffer, "\""); + dStrcat(buffer, "\"", 512); return buffer; } #endif diff --git a/Engine/source/sim/netObject.h b/Engine/source/sim/netObject.h index 7ea1283c4..bbc913c26 100644 --- a/Engine/source/sim/netObject.h +++ b/Engine/source/sim/netObject.h @@ -132,8 +132,8 @@ struct GhostInfo; /// // the ScopeAlways flag indicates that the object is always scoped /// // on all active connections. /// mNetFlags.set(ScopeAlways | Ghostable); -/// dStrcpy(message1, "Hello World 1!"); -/// dStrcpy(message2, "Hello World 2!"); +/// dStrcpy(message1, "Hello World 1!", bufLen); +/// dStrcpy(message2, "Hello World 2!", bufLen); /// } /// @endcode /// @@ -187,12 +187,12 @@ struct GhostInfo; /// void setMessage1(const char *msg) /// { /// setMaskBits(Message1Mask); -/// dStrcpy(message1, msg); +/// dStrcpy(message1, msg, bufLen); /// } /// void setMessage2(const char *msg) /// { /// setMaskBits(Message2Mask); -/// dStrcpy(message2, msg); +/// dStrcpy(message2, msg, bufLen); /// } /// @endcode /// diff --git a/Engine/source/sqlite/SQLiteObject.cpp b/Engine/source/sqlite/SQLiteObject.cpp index 7fe06de5f..a2900ab30 100644 --- a/Engine/source/sqlite/SQLiteObject.cpp +++ b/Engine/source/sqlite/SQLiteObject.cpp @@ -158,18 +158,18 @@ S32 Callback(void *pArg, S32 argc, char **argv, char **columnNames) // DBEUG CODE // Con::printf("%s = %s\n", columnNames[i], argv[i] ? argv[i] : "NULL"); name = new char[dStrlen(columnNames[i]) + 1]; - dStrcpy(name, columnNames[i]); + dStrcpy(name, columnNames[i], dStrlen(columnNames[i]) + 1); pRow->vColumnNames.push_back(name); if (argv[i]) { value = new char[dStrlen(argv[i]) + 1]; - dStrcpy(value, argv[i]); + dStrcpy(value, argv[i], dStrlen(argv[i]) + 1); pRow->vColumnValues.push_back(value); } else { value = new char[10]; - dStrcpy(value, "NULL"); + dStrcpy(value, "NULL", 10); pRow->vColumnValues.push_back(value); } } diff --git a/Engine/source/testing/unitTesting.cpp b/Engine/source/testing/unitTesting.cpp index 2724bf637..a86a28eb3 100644 --- a/Engine/source/testing/unitTesting.cpp +++ b/Engine/source/testing/unitTesting.cpp @@ -99,8 +99,8 @@ DefineConsoleFunction( runAllUnitTests, int, (const char* testSpecs), (""), testArgc = 2; testArgv = new char*[2]; testArgv[0] = NULL; // Program name is unused by googletest. - testArgv[1] = new char[specs.length()+1]; - dStrcpy(testArgv[1], specs); + testArgv[1] = new char[specs.size()]; + dStrcpy(testArgv[1], specs, specs.size()); } // Initialize Google Test.