X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fbase%2Fapplications%2Frapps%2Favailable.c;h=f650af272695f342f791cf5143059fb8505a5b5e;hp=9df29cab489cdc6c8224fc26d6591bf151606f46;hb=6c3df451fba8e3f834b263ed0065d39b2f585eb6;hpb=38e6fa7f14f116cb729df46db032239cf80c1fb3 diff --git a/reactos/base/applications/rapps/available.c b/reactos/base/applications/rapps/available.c index 9df29cab489..f650af27269 100644 --- a/reactos/base/applications/rapps/available.c +++ b/reactos/base/applications/rapps/available.c @@ -46,11 +46,16 @@ DeleteCurrentAppsDB(VOID) WCHAR szSearchPath[MAX_PATH]; WCHAR szPath[MAX_PATH]; WCHAR szTmp[MAX_PATH]; + HRESULT hr; if (!GetStorageDirectory(szPath, sizeof(szPath) / sizeof(szPath[0]))) return FALSE; - swprintf(szCabPath, L"%s\\rappmgr.cab", szPath); + hr = StringCbPrintfW(szCabPath, sizeof(szCabPath), + L"%ls\\rappmgr.cab", + szPath); + if (FAILED(hr)) + return FALSE; if (GetFileAttributesW(szCabPath) != INVALID_FILE_ATTRIBUTES) { @@ -58,8 +63,15 @@ DeleteCurrentAppsDB(VOID) return FALSE; } - wcscat(szPath, L"\\rapps\\"); - swprintf(szSearchPath, L"%s*.txt", szPath); + hr = StringCbCatW(szPath, sizeof(szPath), L"\\rapps\\"); + if (FAILED(hr)) + return FALSE; + + hr = StringCbPrintfW(szSearchPath, sizeof(szSearchPath), + L"%ls*.txt", + szPath); + if (FAILED(hr)) + return FALSE; hFind = FindFirstFileW(szSearchPath, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) @@ -67,8 +79,10 @@ DeleteCurrentAppsDB(VOID) do { - swprintf(szTmp, L"%s%s", szPath, FindFileData.cFileName); - if (!DeleteFileW(szTmp)) + hr = StringCbPrintfW(szTmp, sizeof(szTmp), + L"%ls%ls", + szPath, FindFileData.cFileName); + if (FAILED(hr) || !DeleteFileW(szTmp)) { FindClose(hFind); return FALSE; @@ -97,10 +111,19 @@ UpdateAppsDB(VOID) if (!GetStorageDirectory(szPath, sizeof(szPath) / sizeof(szPath[0]))) return FALSE; - swprintf(szCabPath, L"%s\\rappmgr.cab", szPath); + if (FAILED(StringCbPrintfW(szCabPath, sizeof(szCabPath), + L"%ls\\rappmgr.cab", + szPath))) + { + return FALSE; + } - wcscat(szPath, L"\\rapps\\"); - wcscpy(szAppsPath, szPath); + if (FAILED(StringCbPrintfW(szAppsPath, sizeof(szAppsPath), + L"%ls\\rapps\\", + szPath))) + { + return FALSE; + } ExtractFilesFromCab(szCabPath, szAppsPath); @@ -119,16 +142,25 @@ EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc) WCHAR szCabPath[MAX_PATH]; WCHAR szLocale[4 + 1]; APPLICATION_INFO Info; + HRESULT hr; if (!GetStorageDirectory(szPath, sizeof(szPath) / sizeof(szPath[0]))) { return FALSE; } - swprintf(szCabPath, L"%s\\rappmgr.cab", szPath); + hr = StringCbPrintfW(szCabPath, sizeof(szCabPath), + L"%ls\\rappmgr.cab", + szPath); + if (FAILED(hr)) + return FALSE; - wcscat(szPath, L"\\rapps\\"); - wcscpy(szAppsPath, szPath); + hr = StringCbCatW(szPath, sizeof(szPath), L"\\rapps\\"); + if (FAILED(hr)) + return FALSE; + hr = StringCbCopyW(szAppsPath, sizeof(szAppsPath), szPath); + if (FAILED(hr)) + return FALSE; if (!CreateDirectory(szPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) @@ -137,9 +169,13 @@ EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc) } GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_ILANGUAGE, szLocale, sizeof(szLocale) / sizeof(WCHAR)); - wcscat(szSectionLocale, szLocale); + hr = StringCbCatW(szSectionLocale, sizeof(szSectionLocale), szLocale); + if (FAILED(hr)) + return FALSE; - wcscat(szPath, L"*.txt"); + hr = StringCbCatW(szPath, sizeof(szPath), L"*.txt"); + if (FAILED(hr)) + return FALSE; hFind = FindFirstFileW(szPath, &FindFileData); if (hFind == INVALID_HANDLE_VALUE)