https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cfbec70e0453f84fd24fc48b3924ba25fa078382

commit cfbec70e0453f84fd24fc48b3924ba25fa078382
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Sun Feb 6 21:22:35 2022 +0100
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Sun Feb 6 22:20:58 2022 +0100

    [FREELDR] Use strsafe functions in the PE loader.
---
 boot/freeldr/freeldr/lib/peloader.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/boot/freeldr/freeldr/lib/peloader.c 
b/boot/freeldr/freeldr/lib/peloader.c
index 0b5ca0f87b2..935c0ee8212 100644
--- a/boot/freeldr/freeldr/lib/peloader.c
+++ b/boot/freeldr/freeldr/lib/peloader.c
@@ -245,9 +245,9 @@ PeLdrpBindImportName(
         ((ULONG_PTR)ForwarderName < ((ULONG_PTR)ExportDirectory + ExportSize)))
     {
         PLDR_DATA_TABLE_ENTRY DataTableEntry;
-        CHAR ForwardDllName[255];
         PIMAGE_EXPORT_DIRECTORY RefExportDirectory;
         ULONG RefExportSize;
+        CHAR ForwardDllName[256];
 
         TRACE("PeLdrpBindImportName(): ForwarderName %s\n", ForwarderName);
 
@@ -255,7 +255,7 @@ PeLdrpBindImportName(
         RtlCopyMemory(ForwardDllName, ForwarderName, sizeof(ForwardDllName));
 
         /* Strip out the symbol name */
-        *strrchr(ForwardDllName,'.') = '\0';
+        *strrchr(ForwardDllName, '.') = ANSI_NULL;
 
         /* Check if the target image is already loaded */
         if (!PeLdrCheckForLoadedDll(ModuleListHead, ForwardDllName, 
&DataTableEntry))
@@ -264,7 +264,7 @@ PeLdrpBindImportName(
             if (strchr(ForwardDllName, '.') == NULL)
             {
                 /* Name does not have an extension, append '.dll' */
-                strcat(ForwardDllName, ".dll");
+                RtlStringCbCatA(ForwardDllName, sizeof(ForwardDllName), 
".dll");
             }
 
             /* Now let's try to load it! */
@@ -351,8 +351,8 @@ PeLdrpLoadAndScanReferencedDll(
     PVOID BasePA = NULL;
 
     /* Prepare the full path to the file to be loaded */
-    strcpy(FullDllName, DirectoryPath);
-    strcat(FullDllName, ImportName);
+    RtlStringCbCopyA(FullDllName, sizeof(FullDllName), DirectoryPath);
+    RtlStringCbCatA(FullDllName, sizeof(FullDllName), ImportName);
 
     TRACE("Loading referenced DLL: %s\n", FullDllName);
 

Reply via email to