Преглед на файлове

Linux Support: Make expand path even safer.

Cameron Porter преди 11 години
родител
ревизия
51ef93b9e4
променени са 1 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. 3 3
      engine/source/console/console.cc

+ 3 - 3
engine/source/console/console.cc

@@ -1498,7 +1498,7 @@ bool expandPath( char* pDstPath, U32 size, const char* pSrcPath, const char* pWo
         }
 
         // Yes, so use it as the prefix.
-        dStrcpy(pathBuffer, codeblockFullPath );
+        dStrncpy(pathBuffer, codeblockFullPath, sizeof(pathBuffer) - 1);
 
         // Find the final slash in the code-block.
         pSlash = dStrrchr(pathBuffer, '/');
@@ -1519,8 +1519,8 @@ bool expandPath( char* pDstPath, U32 size, const char* pSrcPath, const char* pWo
         }
            
         // Format the output path.
-        dStrcat(pathBuffer, "/");
-        dStrcat(pathBuffer, pSrc);
+        dStrncat(pathBuffer, "/", sizeof(pathBuffer) - 1 - strlen(pathBuffer));
+        dStrncat(pathBuffer, pSrc, sizeof(pathBuffer) - 1 - strlen(pathBuffer));
 
         // Are we ensuring the trailing slash?
         if ( ensureTrailingSlash )