mirror of
https://github.com/reactos/reactos.git
synced 2024-12-04 08:53:32 +08:00
[APITESTS] Use StringCbPrintfA instead of sprintf
And fix a buffer size in Test_AddFontResourceA
This commit is contained in:
parent
f7dc14cca5
commit
6b10706205
@ -18,9 +18,9 @@ PVOID LoadCodePageData(ULONG Code)
|
||||
GetSystemDirectoryA(sysdir, MAX_PATH);
|
||||
|
||||
if (Code != -1)
|
||||
sprintf(filename, "%s\\c_%lu.nls", sysdir, Code);
|
||||
StringCbPrintfA(filename, sizeof(filename), "%s\\c_%lu.nls", sysdir, Code);
|
||||
else
|
||||
sprintf(filename, "%s\\l_intl.nls", sysdir);
|
||||
StringCbPrintfA(filename, sizeof(filename), "%s\\l_intl.nls", sysdir);
|
||||
|
||||
hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
|
@ -17,6 +17,7 @@
|
||||
#endif
|
||||
#include <winerror.h>
|
||||
#include <stdio.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "apitest_iathook.h"
|
||||
@ -310,9 +311,9 @@ static void test_SdbGetPermLayerKeys(void)
|
||||
skip("Skipping tests for HKLM, cannot alter the registry\n");
|
||||
}
|
||||
/* Fail from these paths */
|
||||
sprintf(tmp, "\\?\\%s", file);
|
||||
StringCbPrintfA(tmp, sizeof(tmp), "\\?\\%s", file);
|
||||
expect_Sdb(tmp, GPLK_USER, FALSE, 0xffffffff, "");
|
||||
sprintf(tmp, "\\??\\%s", file);
|
||||
StringCbPrintfA(tmp, sizeof(tmp), "\\??\\%s", file);
|
||||
expect_Sdb(tmp, GPLK_USER, FALSE, 0xffffffff, "");
|
||||
|
||||
ok(setLayerValue(FALSE, file, "!#!# RUNASADMIN RUNASADMIN !# WINXPSP3 "), "Expected setLayerValue not to fail\n");
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
void Test_AddFontResourceA()
|
||||
{
|
||||
CHAR szFileNameA[MAX_PATH];
|
||||
CHAR szFileNameA[MAX_PATH*2 + 3];
|
||||
CHAR szFileNameFont1A[MAX_PATH];
|
||||
CHAR szFileNameFont2A[MAX_PATH];
|
||||
int result;
|
||||
@ -24,7 +24,7 @@ void Test_AddFontResourceA()
|
||||
memcpy(szFileNameFont2A,szFileNameA,MAX_PATH );
|
||||
strcat(szFileNameFont2A, "\\bin\\testdata\\test.otf");
|
||||
|
||||
RtlZeroMemory(szFileNameA,MAX_PATH);
|
||||
RtlZeroMemory(szFileNameA, sizeof(szFileNameA));
|
||||
|
||||
/*
|
||||
* Start testing Ansi version
|
||||
|
@ -73,7 +73,7 @@ TestGetVolumeInformationW(VOID)
|
||||
WCHAR Outbuf[MAX_PATH];
|
||||
DWORD i, MCL, Flags, Len;
|
||||
|
||||
memset(Outbuf, 0xAA, MAX_PATH);
|
||||
memset(Outbuf, 0xAA, sizeof(Outbuf));
|
||||
Ret = GetVolumeInformationW(L"C:\\", NULL, 0, NULL, &MCL, &Flags, Outbuf, MAX_PATH);
|
||||
ok(Ret != FALSE, "GetVolumeInformationW failed: %ld\n", GetLastError());
|
||||
for (i = 0; i < MAX_PATH; ++i)
|
||||
@ -85,7 +85,7 @@ TestGetVolumeInformationW(VOID)
|
||||
}
|
||||
ok(i != MAX_PATH, "String was not null terminated!\n");
|
||||
|
||||
memset(Outbuf, 0xAA, MAX_PATH);
|
||||
memset(Outbuf, 0xAA, sizeof(Outbuf));
|
||||
Len = i;
|
||||
Ret = GetVolumeInformationW(L"C:\\", NULL, 0, NULL, &MCL, &Flags, Outbuf, Len + 1);
|
||||
ok(Ret != FALSE, "GetVolumeInformationW failed: %ld\n", GetLastError());
|
||||
@ -99,7 +99,7 @@ TestGetVolumeInformationW(VOID)
|
||||
ok(i != MAX_PATH, "String was not null terminated!\n");
|
||||
ok(i == Len, "String was truncated\n");
|
||||
|
||||
memset(Outbuf, 0xAA, MAX_PATH);
|
||||
memset(Outbuf, 0xAA, sizeof(Outbuf));
|
||||
Len = i;
|
||||
SetLastError(0xdeadbeef);
|
||||
Ret = GetVolumeInformationW(L"C:\\", NULL, 0, NULL, &MCL, &Flags, Outbuf, Len);
|
||||
|
@ -57,7 +57,7 @@ typedef struct UNICODE_STRING {
|
||||
USHORT Length;
|
||||
USHORT MaximumLength;
|
||||
PWSTR Buffer;
|
||||
} UNICODE_STRING, *PUNICODE_STRING;
|
||||
} UNICODE_STRING, *PUNICODE_STRING;
|
||||
|
||||
typedef struct _RTLP_CURDIR_REF
|
||||
{
|
||||
@ -207,7 +207,8 @@ typedef struct DirComponents
|
||||
char szCD[512];
|
||||
char szCDPlusSlash[512];
|
||||
char* pszLastCDComponent;
|
||||
char szCurDrive[4];
|
||||
char szCurDrive[3];
|
||||
char reserved1;
|
||||
char szCurDriveSlash[4];
|
||||
char szParentDir[512];
|
||||
char szParentDirPlusSlash[512];
|
||||
@ -346,7 +347,7 @@ int main()
|
||||
#endif // PRINT_INFO
|
||||
|
||||
DirComponents cd;
|
||||
char szTmp[512];
|
||||
char szTmp[518];
|
||||
|
||||
#ifndef COMPILE_AS_ROSTEST
|
||||
InitFunctionPointer();
|
||||
|
@ -76,9 +76,9 @@ PVOID LoadCodePageData(ULONG Code)
|
||||
GetSystemDirectoryA(sysdir, MAX_PATH);
|
||||
|
||||
if (Code != -1)
|
||||
sprintf(filename, "%s\\c_%lu.nls", sysdir, Code);
|
||||
StringCbPrintfA(filename, sizeof(filename), "%s\\c_%lu.nls", sysdir, Code);
|
||||
else
|
||||
sprintf(filename, "%s\\l_intl.nls", sysdir);
|
||||
StringCbPrintfA(filename, sizeof(filename), "%s\\l_intl.nls", sysdir);
|
||||
|
||||
hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <winreg.h>
|
||||
#include <winsvc.h>
|
||||
#include <setupapi.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
static const char inffile[] = "test.inf";
|
||||
static char CURR_DIR[MAX_PATH];
|
||||
@ -56,7 +57,7 @@ static void test_SetupDiInstallClassExA(void)
|
||||
/* [Version]:Signature */
|
||||
strcpy(inf, "[Version]\nSignature=\"$Chicago$\"\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = SetupDiInstallClassExA(NULL, path, DI_QUIETINSTALL, NULL, NULL, NULL,NULL);
|
||||
@ -68,7 +69,7 @@ static void test_SetupDiInstallClassExA(void)
|
||||
/* [Version]:Signature+Class */
|
||||
strcat(inf, "Class=MySampleClass\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = SetupDiInstallClassExA(NULL, path, DI_QUIETINSTALL, NULL, NULL, NULL,NULL);
|
||||
@ -80,7 +81,7 @@ static void test_SetupDiInstallClassExA(void)
|
||||
/* [Version]:Signature+Class+ClassGUID */
|
||||
strcat(inf, "ClassGuid={3b409830-5f9d-432a-abf5-7d2e4e102467}\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = SetupDiInstallClassExA(NULL, path, DI_QUIETINSTALL, NULL, NULL, NULL,NULL);
|
||||
@ -92,7 +93,7 @@ static void test_SetupDiInstallClassExA(void)
|
||||
/* [Version]Signature+Class+ClassGUID;[ClassInstall32.NT]Empty */
|
||||
strcat(inf, "[ClassInstall32.NT]\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = SetupDiInstallClassExA(NULL, path, DI_QUIETINSTALL, NULL, NULL, NULL,NULL);
|
||||
@ -104,13 +105,13 @@ static void test_SetupDiInstallClassExA(void)
|
||||
{
|
||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM", 0, KEY_ALL_ACCESS, &RegHandle);
|
||||
del = RegDeleteKeyW(RegHandle, L"CurrentControlSet\\Control\\Class\\{3B409830-5F9D-432A-ABF5-7D2E4E102467}");
|
||||
ok(del == ERROR_SUCCESS, "Expected success \n");
|
||||
ok(del == ERROR_SUCCESS, "Expected success \n");
|
||||
}
|
||||
|
||||
/* [Version]Signature+Class+ClassGUID;[ClassInstall32.NT]AddReg */
|
||||
strcat(inf, "AddReg=SampleClassAddReg\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = SetupDiInstallClassExA(NULL, path, DI_QUIETINSTALL, NULL, NULL, NULL,NULL);
|
||||
@ -122,13 +123,13 @@ static void test_SetupDiInstallClassExA(void)
|
||||
{
|
||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM", 0, KEY_ALL_ACCESS, &RegHandle);
|
||||
del = RegDeleteKeyW(RegHandle, L"CurrentControlSet\\Control\\Class\\{3B409830-5F9D-432A-ABF5-7D2E4E102467}");
|
||||
ok(del == ERROR_SUCCESS, "Expected success \n");
|
||||
ok(del == ERROR_SUCCESS, "Expected success \n");
|
||||
}
|
||||
|
||||
/* [Version]Signature+Class+ClassGUID;[ClassInstall32.NT]AddReg; [SampleClassAddReg];*/
|
||||
strcat(inf, "[SampleClassAddReg]\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = SetupDiInstallClassExA(NULL, path, DI_QUIETINSTALL, NULL, NULL, NULL,NULL);
|
||||
@ -140,13 +141,13 @@ static void test_SetupDiInstallClassExA(void)
|
||||
{
|
||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM", 0, KEY_ALL_ACCESS, &RegHandle);
|
||||
del = RegDeleteKeyW(RegHandle, L"CurrentControlSet\\Control\\Class\\{3B409830-5F9D-432A-ABF5-7D2E4E102467}");
|
||||
ok(del == ERROR_SUCCESS, "Expected success \n");
|
||||
ok(del == ERROR_SUCCESS, "Expected success \n");
|
||||
}
|
||||
|
||||
/* [Version]Signature+Class+ClassGUID;[ClassInstall32.NT]AddReg; [SampleClassAddReg]HKR;*/
|
||||
strcat(inf, "HKR,,,,\"ReactOS Test SetupDiInstallClassExA\"\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = SetupDiInstallClassExA(NULL, path, DI_QUIETINSTALL, NULL, NULL, NULL,NULL);
|
||||
@ -158,13 +159,13 @@ static void test_SetupDiInstallClassExA(void)
|
||||
{
|
||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM", 0, KEY_ALL_ACCESS, &RegHandle);
|
||||
del = RegDeleteKeyW(RegHandle, L"CurrentControlSet\\Control\\Class\\{3B409830-5F9D-432A-ABF5-7D2E4E102467}");
|
||||
ok(del == ERROR_SUCCESS, "Expected success \n");
|
||||
ok(del == ERROR_SUCCESS, "Expected success \n");
|
||||
}
|
||||
|
||||
/*[Version]Signature+Class+ClassGUID;[ClassInstall32.NT]AddReg;[SampleClassAddReg]HKR;[ClassInstall32.NT.Services]*/
|
||||
strcat(inf, "[ClassInstall32.NT.Services]\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = SetupDiInstallClassExA(NULL, path, DI_QUIETINSTALL, NULL, NULL, NULL,NULL);
|
||||
@ -176,7 +177,7 @@ static void test_SetupDiInstallClassExA(void)
|
||||
{
|
||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM", 0, KEY_ALL_ACCESS, &RegHandle);
|
||||
del = RegDeleteKeyW(RegHandle, L"CurrentControlSet\\Control\\Class\\{3B409830-5F9D-432A-ABF5-7D2E4E102467}");
|
||||
ok(del == ERROR_SUCCESS, "Expected success\n");
|
||||
ok(del == ERROR_SUCCESS, "Expected success\n");
|
||||
}
|
||||
|
||||
/* Add a reference */
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <winreg.h>
|
||||
#include <winsvc.h>
|
||||
#include <setupapi.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
static const char inffile[] = "test.inf";
|
||||
static char CURR_DIR[MAX_PATH];
|
||||
@ -72,7 +73,7 @@ static void test_SetupInstallServicesFromInfSectionExA(void)
|
||||
/* Basic inf file to satisfy SetupOpenInfFileA */
|
||||
strcpy(inf, "[Version]\nSignature=\"$Chicago$\"\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
infhandle = SetupOpenInfFileA(path, NULL, INF_STYLE_WIN4, NULL);
|
||||
|
||||
/* Nothing but the Version section */
|
||||
@ -193,7 +194,7 @@ static void test_SetupInstallServicesFromInfSectionExA(void)
|
||||
strcat(inf, "[XSP.InstallPerVer]\n");
|
||||
strcat(inf, "AddReg=AspEventlogMsg.Reg,Perf.Reg,AspVersions.Reg,FreeADO.Reg,IndexServer.Reg\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
infhandle = SetupOpenInfFileA(path, NULL, INF_STYLE_WIN4, NULL);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
@ -227,7 +228,7 @@ static void test_SetupInstallServicesFromInfSectionExW(void)
|
||||
/* Basic inf file to satisfy SetupOpenInfFileA */
|
||||
strcpy(inf, "[Version]\nSignature=\"$Chicago$\"\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
infhandle = SetupOpenInfFileA(path, NULL, INF_STYLE_WIN4, NULL);
|
||||
|
||||
/* Nothing but the Version section */
|
||||
@ -348,7 +349,7 @@ static void test_SetupInstallServicesFromInfSectionExW(void)
|
||||
strcat(inf, "[XSP.InstallPerVer]\n");
|
||||
strcat(inf, "AddReg=AspEventlogMsg.Reg,Perf.Reg,AspVersions.Reg,FreeADO.Reg,IndexServer.Reg\n");
|
||||
create_inf_file(inffile, inf);
|
||||
sprintf(path, "%s\\%s", CURR_DIR, inffile);
|
||||
StringCbPrintfA(path, sizeof(path), "%s\\%s", CURR_DIR, inffile);
|
||||
infhandle = SetupOpenInfFileA(path, NULL, INF_STYLE_WIN4, NULL);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
@ -364,7 +365,7 @@ static void test_SetupInstallServicesFromInfSectionExW(void)
|
||||
|
||||
START_TEST(SetupInstallServicesFromInfSectionEx)
|
||||
{
|
||||
char temp_path[MAX_PATH], prev_path[MAX_PATH];
|
||||
char temp_path[MAX_PATH], prev_path[MAX_PATH];
|
||||
|
||||
GetCurrentDirectoryA(MAX_PATH, prev_path);
|
||||
GetTempPathA(MAX_PATH, temp_path);
|
||||
|
Loading…
Reference in New Issue
Block a user