[SETUPLIB][USETUP] Use NT RTL String Safe functions instead of Win32-oriented ones...
[reactos.git] / base / setup / lib / settings.c
index 4e27d03..060c671 100644 (file)
@@ -422,7 +422,7 @@ DefaultProcessEntry(
     }
 
     wcscpy((PWCHAR)*UserData, KeyName);
-    wcscpy(DisplayText, KeyValue);
+    RtlStringCbCopyW(DisplayText, DisplayTextSize, KeyValue);
 
     *Current = (CompareKey ? !_wcsicmp(KeyName, CompareKey) : FALSE);
 
@@ -483,7 +483,7 @@ CreateComputerTypeList(
         }
 
         DPRINT("Computer key: %S\n", KeyName);
-        wcscpy(ComputerKey, KeyName);
+        RtlStringCchCopyW(ComputerKey, ARRAYSIZE(ComputerKey), KeyName);
         INF_FreeData(KeyName);
     } while (SetupFindNextLine(&Context, &Context));
 
@@ -548,7 +548,7 @@ GetDisplayIdentifier(
     BusInstance = 0;
     while (TRUE)
     {
-        swprintf(Buffer, L"%lu", BusInstance);
+        RtlStringCchPrintfW(Buffer, ARRAYSIZE(Buffer), L"%lu", BusInstance);
         RtlInitUnicodeString(&KeyName, Buffer);
         InitializeObjectAttributes(&ObjectAttributes,
                                    &KeyName,
@@ -584,7 +584,7 @@ GetDisplayIdentifier(
             while (TRUE)
             {
                 /* Open the pointer controller instance key */
-                swprintf(Buffer, L"%lu", ControllerInstance);
+                RtlStringCchPrintfW(Buffer, ARRAYSIZE(Buffer), L"%lu", ControllerInstance);
                 RtlInitUnicodeString(&KeyName, Buffer);
                 InitializeObjectAttributes(&ObjectAttributes,
                                            &KeyName,
@@ -719,7 +719,7 @@ CreateDisplayDriverList(
         }
 
         DPRINT("Display key: %S\n", KeyName);
-        wcscpy(DisplayKey, KeyName);
+        RtlStringCchCopyW(DisplayKey, ARRAYSIZE(DisplayKey), KeyName);
         INF_FreeData(KeyName);
     } while (SetupFindNextLine(&Context, &Context));
 
@@ -764,8 +764,8 @@ ProcessComputerFiles(
         return FALSE;
     }
 
-    wcscpy(SectionName, L"Files.");
-    wcscat(SectionName, (const wchar_t*)GetListEntryUserData(Entry));
+    RtlStringCchPrintfW(SectionName, ARRAYSIZE(SectionName),
+                        L"Files.%s", (PCWSTR)GetListEntryUserData(Entry));
     *AdditionalSectionName = SectionName;
 
     return TRUE;
@@ -813,7 +813,9 @@ ProcessDisplayRegistry(
     ASSERT(wcslen(ServiceName) < 10);
     DPRINT1("Service name: '%S'\n", ServiceName);
 
-    swprintf(RegPath, L"System\\CurrentControlSet\\Services\\%s", ServiceName);
+    RtlStringCchPrintfW(RegPath, ARRAYSIZE(RegPath),
+                        L"System\\CurrentControlSet\\Services\\%s",
+                        ServiceName);
     RtlInitUnicodeString(&KeyName, RegPath);
     InitializeObjectAttributes(&ObjectAttributes,
                                &KeyName,
@@ -850,9 +852,9 @@ ProcessDisplayRegistry(
         return FALSE;
     }
 
-    swprintf(RegPath,
-             L"System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\%s\\Device0",
-             ServiceName);
+    RtlStringCchPrintfW(RegPath, ARRAYSIZE(RegPath),
+                        L"System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\%s\\Device0",
+                        ServiceName);
     DPRINT1("RegPath: '%S'\n", RegPath);
     RtlInitUnicodeString(&KeyName, RegPath);
     InitializeObjectAttributes(&ObjectAttributes,
@@ -1110,7 +1112,7 @@ ProcessLangEntry(
     }
 
     wcscpy((PWCHAR)*UserData, KeyName);
-    wcscpy(DisplayText, KeyValue);
+    RtlStringCbCopyW(DisplayText, DisplayTextSize, KeyValue);
 
     *Current = FALSE;