Correct pointless and bad buffer sizing in RegisterApplicationRestart

This commit is contained in:
Marek Roszko 2021-02-01 15:35:54 -05:00
parent 29632e8b6f
commit 06a515339c
1 changed files with 7 additions and 5 deletions

View File

@ -30,13 +30,15 @@
bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine ) bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine )
{ {
HRESULT hr = S_OK; // not if registering for recovery and restart fails. // Ensure we don't exceed the maximum allowable size
WCHAR wsCommandLine[RESTART_MAX_CMD_LINE]; if( aCommandLine.length() > RESTART_MAX_CMD_LINE - 1 )
RtlZeroMemory( wsCommandLine, sizeof( wsCommandLine ) ); {
return false;
}
StringCchCopyW( wsCommandLine, sizeof( wsCommandLine ), aCommandLine.wc_str() ); HRESULT hr = S_OK;
hr = ::RegisterApplicationRestart( wsCommandLine, RESTART_NO_PATCH ); hr = ::RegisterApplicationRestart( aCommandLine.wc_str(), RESTART_NO_PATCH );
return SUCCEEDED( hr ); return SUCCEEDED( hr );
} }