-
Notifications
You must be signed in to change notification settings - Fork 63
Description
Description
Access violation occurs if NetCoreCheck.exe fails to open a Temp Runtime Config File TestXXX.runtimeconfig.json
for writing. This is reproducible with file version 1.0.2.0 from netcorecheck x64 7.0.0 and seems to be reproducible with the current main 1478b7e.
To reproduce, place NetCoreCheck.exe to a folder where the current user can't create files, e.g. forbidden by NTFS security. The current working folder is not important. Run the command:
Path\to\Restricted\Folder\NetCoreCheck.exe --runtimename Microsoft.WindowsDesktop.App --runtimeversion 8.0.15
Expected behavior: this is tricky because thanks to this crash I found a bug in an installer wizard. If from now we just print an error and exit then a program that just checks the exit status would think that the runtime version is not installed. So maybe print the error and crash anyway with throw or std::abort()
.
Actual: Access Violation (crash dialog may be disabled in group policy, but an error entry will be created in the Windows Application Log),
Clearly, there's a bug in a printf-like call where DWORD value is passed in place of a string conversion specifier %s.
deployment-tools/src/clickonce/native/projects/NetCoreCheck/TempRuntimeConfigFile.cpp
Line 84 in 1478b7e
g_log->Log(TEXT("Open file failed : '%s'."), ret); |
I also think that the Log function can be marked as printf-like to avoid such problems in the future:
#include <sal.h> // for _Printf_format_string_
class Logger
{
public:
virtual void Log(_Printf_format_string_ LPCWSTR pszFormat, ...) const noexcept = 0;
...
It's unclear what the correct error message display: the error code, the path, or both.
This was found in an installer wizard that creates a temp folder and unpacks NetCoreCheck.exe in an elevated mode and with NTFS inheritance disabled and runs it in a regular mode.