Author: hbelusca
Date: Sun Sep 3 20:34:29 2017
New Revision: 75757
URL:
http://svn.reactos.org/svn/reactos?rev=75757&view=rev
Log:
[SETUPLIB]: Use strsafe functions (cont).
Modified:
branches/setup_improvements/base/setup/lib/bootsup.c
branches/setup_improvements/base/setup/lib/mui.c
branches/setup_improvements/base/setup/lib/settings.c
branches/setup_improvements/base/setup/lib/setuplib.c
Modified: branches/setup_improvements/base/setup/lib/bootsup.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/bootsup.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/bootsup.c [iso-8859-1] Sun Sep 3 20:34:29
2017
@@ -368,7 +368,7 @@
goto SkipThisEntry;
}
- swprintf(SystemPath, L"\"%s\"", Data->ArcPath);
+ StringCchPrintfW(SystemPath, ARRAYSIZE(SystemPath), L"\"%s\"",
Data->ArcPath);
if ((_wcsicmp(Options->OsLoadPath, Data->ArcPath) != 0) &&
(_wcsicmp(Options->OsLoadPath, SystemPath) != 0))
{
Modified: branches/setup_improvements/base/setup/lib/mui.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/mui.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/mui.c [iso-8859-1] Sun Sep 3 20:34:29
2017
@@ -298,10 +298,10 @@
{
if (uIndex > 19) break;
- swprintf(szValueName, L"%u", uIndex + 1);
+ StringCchPrintfW(szValueName, ARRAYSIZE(szValueName), L"%u", uIndex +
1);
RtlInitUnicodeString(&ValueName, szValueName);
- swprintf(szLangID, L"0000%s", MuiLayouts[uIndex].LangID);
+ StringCchPrintfW(szLangID, ARRAYSIZE(szLangID), L"0000%s",
MuiLayouts[uIndex].LangID);
if (_wcsicmp(szLangID, MuiLayouts[uIndex].LayoutID) == 0)
{
@@ -321,7 +321,7 @@
}
else
{
- swprintf(szLangID, L"d%03lu%s", uCount,
MuiLayouts[uIndex].LangID);
+ StringCchPrintfW(szLangID, ARRAYSIZE(szLangID), L"d%03lu%s",
uCount, MuiLayouts[uIndex].LangID);
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
Modified: branches/setup_improvements/base/setup/lib/settings.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/settings.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/settings.c [iso-8859-1] Sun Sep 3 20:34:29
2017
@@ -423,7 +423,7 @@
}
wcscpy((PWCHAR)*UserData, KeyName);
- wcscpy(DisplayText, KeyValue);
+ StringCbCopyW(DisplayText, DisplayTextSize, KeyValue);
*Current = (CompareKey ? !_wcsicmp(KeyName, CompareKey) : FALSE);
@@ -484,7 +484,7 @@
}
DPRINT("Computer key: %S\n", KeyName);
- wcscpy(ComputerKey, KeyName);
+ StringCchCopyW(ComputerKey, ARRAYSIZE(ComputerKey), KeyName);
INF_FreeData(KeyName);
} while (SetupFindNextLine(&Context, &Context));
@@ -549,7 +549,7 @@
BusInstance = 0;
while (TRUE)
{
- swprintf(Buffer, L"%lu", BusInstance);
+ StringCchPrintfW(Buffer, ARRAYSIZE(Buffer), L"%lu", BusInstance);
RtlInitUnicodeString(&KeyName, Buffer);
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
@@ -585,7 +585,7 @@
while (TRUE)
{
/* Open the pointer controller instance key */
- swprintf(Buffer, L"%lu", ControllerInstance);
+ StringCchPrintfW(Buffer, ARRAYSIZE(Buffer), L"%lu",
ControllerInstance);
RtlInitUnicodeString(&KeyName, Buffer);
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
@@ -720,7 +720,7 @@
}
DPRINT("Display key: %S\n", KeyName);
- wcscpy(DisplayKey, KeyName);
+ StringCchCopyW(DisplayKey, ARRAYSIZE(DisplayKey), KeyName);
INF_FreeData(KeyName);
} while (SetupFindNextLine(&Context, &Context));
@@ -765,8 +765,8 @@
return FALSE;
}
- wcscpy(SectionName, L"Files.");
- wcscat(SectionName, (const wchar_t*)GetListEntryUserData(Entry));
+ StringCchPrintfW(SectionName, ARRAYSIZE(SectionName),
+ L"Files.%s", (PCWSTR)GetListEntryUserData(Entry));
*AdditionalSectionName = SectionName;
return TRUE;
@@ -814,7 +814,9 @@
ASSERT(wcslen(ServiceName) < 10);
DPRINT1("Service name: '%S'\n", ServiceName);
- swprintf(RegPath, L"System\\CurrentControlSet\\Services\\%s",
ServiceName);
+ StringCchPrintfW(RegPath, ARRAYSIZE(RegPath),
+ L"System\\CurrentControlSet\\Services\\%s",
+ ServiceName);
RtlInitUnicodeString(&KeyName, RegPath);
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
@@ -851,9 +853,9 @@
return FALSE;
}
- swprintf(RegPath,
- L"System\\CurrentControlSet\\Hardware
Profiles\\Current\\System\\CurrentControlSet\\Services\\%s\\Device0",
- ServiceName);
+ StringCchPrintfW(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,
@@ -1111,7 +1113,7 @@
}
wcscpy((PWCHAR)*UserData, KeyName);
- wcscpy(DisplayText, KeyValue);
+ StringCbCopyW(DisplayText, DisplayTextSize, KeyValue);
*Current = FALSE;
Modified: branches/setup_improvements/base/setup/lib/setuplib.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/setuplib.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/setuplib.c [iso-8859-1] Sun Sep 3 20:34:29
2017
@@ -144,7 +144,11 @@
DPRINT("INF_GetData() failed for key
'InstallationDirectory'\n");
goto Quit;
}
- wcscpy(pSetupData->InstallationDirectory, Value);
+
+ StringCchCopyW(pSetupData->InstallationDirectory,
+ ARRAYSIZE(pSetupData->InstallationDirectory),
+ Value);
+
INF_FreeData(Value);
}
@@ -186,7 +190,9 @@
if (INF_GetData(&Context, NULL, &Value))
{
LONG Id = wcstol(Value, NULL, 16);
- swprintf(pSetupData->LocaleID, L"%08lx", Id);
+ StringCchPrintfW(pSetupData->LocaleID,
+ ARRAYSIZE(pSetupData->LocaleID),
+ L"%08lx", Id);
INF_FreeData(Value);
}
}
@@ -558,7 +564,10 @@
if (!INF_GetData(&Context, NULL, &Value))
return ERROR_CORRUPT_TXTSETUPSIF;
- wcscpy(pSetupData->InstallationDirectory, Value);
+ StringCchCopyW(pSetupData->InstallationDirectory,
+ ARRAYSIZE(pSetupData->InstallationDirectory),
+ Value);
+
INF_FreeData(Value);
}