Przeglądaj źródła

Linux Support: Make expand path even safer.

Cameron Porter 11 lat temu
rodzic
commit
51ef93b9e4
1 zmienionych plików z 3 dodań i 3 usunięć
  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.
         // Yes, so use it as the prefix.
-        dStrcpy(pathBuffer, codeblockFullPath );
+        dStrncpy(pathBuffer, codeblockFullPath, sizeof(pathBuffer) - 1);
 
 
         // Find the final slash in the code-block.
         // Find the final slash in the code-block.
         pSlash = dStrrchr(pathBuffer, '/');
         pSlash = dStrrchr(pathBuffer, '/');
@@ -1519,8 +1519,8 @@ bool expandPath( char* pDstPath, U32 size, const char* pSrcPath, const char* pWo
         }
         }
            
            
         // Format the output path.
         // 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?
         // Are we ensuring the trailing slash?
         if ( ensureTrailingSlash )
         if ( ensureTrailingSlash )