diff options
Diffstat (limited to 'setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx')
-rw-r--r-- | setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx b/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx index 4f2fb4ebcecd..4d78d7dc5e08 100644 --- a/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx +++ b/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx @@ -18,8 +18,8 @@ */ #include "shlxtmsi.hxx" - -#include <malloc.h> +#include <algorithm> +#include <systools/win32/uwinapi.h> extern "C" UINT __stdcall MigrateInstallPath( MSIHANDLE handle ) { @@ -40,6 +40,7 @@ extern "C" UINT __stdcall MigrateInstallPath( MSIHANDLE handle ) { if ( ERROR_SUCCESS == RegQueryValueExW( hKey, L"INSTALLLOCATION", nullptr, nullptr, reinterpret_cast<LPBYTE>(szValue), &nValueSize ) ) { + szValue[std::min(unsigned int(SAL_N_ELEMENTS(szValue) - 1), unsigned int(nValueSize / sizeof(*szValue)))] = 0; sInstDir = szValue; MsiSetPropertyW(handle, L"INSTALLLOCATION", sInstDir.c_str()); // MessageBoxW( NULL, sInstDir.c_str(), L"Found in HKEY_CURRENT_USER", MB_OK ); @@ -51,6 +52,7 @@ extern "C" UINT __stdcall MigrateInstallPath( MSIHANDLE handle ) { if ( ERROR_SUCCESS == RegQueryValueExW( hKey, L"INSTALLLOCATION", nullptr, nullptr, reinterpret_cast<LPBYTE>(szValue), &nValueSize ) ) { + szValue[std::min(unsigned int(SAL_N_ELEMENTS(szValue) - 1), unsigned int(nValueSize / sizeof(*szValue)))] = 0; sInstDir = szValue; MsiSetPropertyW(handle, L"INSTALLLOCATION", sInstDir.c_str()); // MessageBoxW( NULL, sInstDir.c_str(), L"Found in HKEY_LOCAL_MACHINE", MB_OK ); |