https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5aafeb473f6adeded7ad86f43d8aa72882ed0f58
commit 5aafeb473f6adeded7ad86f43d8aa72882ed0f58 Author: Jérôme Gardou <jerome.gar...@reactos.org> AuthorDate: Thu Jun 17 15:50:54 2021 +0200 Commit: Jérôme Gardou <zefk...@users.noreply.github.com> CommitDate: Mon Jun 28 10:20:57 2021 +0200 [FLTMC] Do not ignore failures of some functions Also reduce use of magic values. CORE-17637 --- base/applications/fltmc/fltmc.cpp | 70 ++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/base/applications/fltmc/fltmc.cpp b/base/applications/fltmc/fltmc.cpp index 689efa3cdc8..36d81cb034d 100644 --- a/base/applications/fltmc/fltmc.cpp +++ b/base/applications/fltmc/fltmc.cpp @@ -61,7 +61,7 @@ SetDriverLoadPrivilege() LUID luid; BOOL bSuccess; DWORD dwError = ERROR_SUCCESS; - + bSuccess = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken); @@ -220,7 +220,8 @@ PrintVolumeInfo(_In_ PVOID Buffer) VolName[FilterVolInfo->FilterVolumeNameLength] = UNICODE_NULL; } - (void)FilterGetDosName(VolName, DosName, 16); + if (!SUCCEEDED(FilterGetDosName(VolName, DosName, _countof(DosName)))) + DosName[0] = L'\0'; switch (FilterVolInfo->FileSystemType) { @@ -271,7 +272,7 @@ ListFilters() hr = FilterFindFirst(FilterAggregateStandardInformation, Buffer, - 1024, + sizeof(Buffer), &BytesReturned, &FindHandle); if (!SUCCEEDED(hr)) @@ -279,44 +280,51 @@ ListFilters() IsNewStyle = FALSE; hr = FilterFindFirst(FilterFullInformation, Buffer, - 1024, + sizeof(Buffer), &BytesReturned, &FindHandle); } - if (SUCCEEDED(hr)) + if (!SUCCEEDED(hr)) + { + LoadAndPrintString(IDS_ERROR_FILTERS, hr); + PrintErrorText(hr); + return; + } + + if (IsNewStyle) + { + LoadAndPrintString(IDS_DISPLAY_FILTERS1); + wprintf(L"------------------------------ ------------- ------------ -----\n"); + } + else { - if (IsNewStyle) + LoadAndPrintString(IDS_DISPLAY_FILTERS2); + wprintf(L"------------------------------ ------------- -----\n"); + } + + PrintFilterInfo(Buffer, IsNewStyle); + + do + { + hr = FilterFindNext(FindHandle, + IsNewStyle ? FilterAggregateStandardInformation : FilterFullInformation, + Buffer, + sizeof(Buffer), + &BytesReturned); + if (SUCCEEDED(hr)) { - LoadAndPrintString(IDS_DISPLAY_FILTERS1); - wprintf(L"------------------------------ ------------- ------------ -----\n"); + PrintFilterInfo(Buffer, IsNewStyle); } - else + else if (hr != HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS)) { - LoadAndPrintString(IDS_DISPLAY_FILTERS2); - wprintf(L"------------------------------ ------------- -----\n"); + LoadAndPrintString(IDS_ERROR_FILTERS, hr); + PrintErrorText(hr); } + } while (SUCCEEDED(hr)); - PrintFilterInfo(Buffer, IsNewStyle); - - do - { - hr = FilterFindNext(FindHandle, - IsNewStyle ? FilterAggregateStandardInformation : FilterFullInformation, - Buffer, - 1024, - &BytesReturned); - if (SUCCEEDED(hr)) - { - PrintFilterInfo(Buffer, IsNewStyle); - } - - } while (SUCCEEDED(hr)); - - FilterFindClose(FindHandle); - } - - if (!SUCCEEDED(hr) && hr != HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS)) + hr = FilterFindClose(FindHandle); + if (!SUCCEEDED(hr)) { LoadAndPrintString(IDS_ERROR_FILTERS, hr); PrintErrorText(hr);