Ver código fonte

More cats and cpys in files that xcode doesn't see

Glenn Smith 7 anos atrás
pai
commit
963333c583

+ 1 - 1
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);
   */
 

+ 4 - 4
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;
 }

+ 2 - 2
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;
 }
 

+ 1 - 1
Engine/source/core/frameAllocator.h

@@ -185,7 +185,7 @@ public:
 /// the FrameAllocator. For example:
 /// @code
 /// FrameTemp<char> 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 );

+ 2 - 2
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);

+ 6 - 6
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" );

+ 1 - 1
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;

+ 1 - 1
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();
 
    //

+ 1 - 1
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);

+ 1 - 1
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();
 
    //

+ 5 - 5
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)

+ 1 - 1
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)

+ 3 - 3
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)

+ 1 - 1
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" );

+ 1 - 1
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__)
 }
 

+ 1 - 1
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()

+ 1 - 1
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;
       //   }
       //}

+ 1 - 1
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

+ 4 - 4
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
 ///

+ 3 - 3
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);
 		}
 	}

+ 2 - 2
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.