Fixed a problem with how config validation was done.

master
Pacman Ghost 7 years ago
parent 31eb99d883
commit 3c9b363483
  1. 2
      MouseDll/appProfile.cpp
  2. 6
      MouseDll/core.cpp
  3. 6
      MouseDll/deviceConfig.cpp

@ -21,7 +21,7 @@ AppProfile::AppProfile(
{
const ApiEvent* pEvent = pEvents + i ;
// validate the Action index/count
if ( pEvent->mActionStartIndex < 0 || (pEvent->mActionStartIndex > 0 && pEvent->mActionStartIndex >= nActions) )
if ( pEvent->mActionStartIndex < 0 || (pEvent->mActionCount > 0 && pEvent->mActionStartIndex >= nActions) )
{
throw runtime_error(
MAKE_STRING(

@ -102,8 +102,8 @@ reloadConfig(
for ( int i=0 ; i < nDeviceConfigs ; ++i )
{
const ApiDeviceConfig* pDeviceConfig = pDeviceConfigs + i ;
// validate the AppProfile index/count
if ( pDeviceConfig->mAppProfileStartIndex < 0 || (pDeviceConfig->mAppProfileStartIndex > 0 && pDeviceConfig->mAppProfileStartIndex >= nAppProfiles) )
// validate the AppProfile start index and count
if ( pDeviceConfig->mAppProfileStartIndex < 0 || (pDeviceConfig->mAppProfileCount > 0 && pDeviceConfig->mAppProfileStartIndex >= nAppProfiles) )
{
throw runtime_error(
MAKE_STRING(
@ -112,7 +112,7 @@ reloadConfig(
)
) ;
}
if ( pDeviceConfig->mAppProfileCount < 0 || pDeviceConfig->mAppProfileStartIndex + pDeviceConfig->mAppProfileCount > nAppProfiles )
if ( pDeviceConfig->mAppProfileCount < 0 || (pDeviceConfig->mAppProfileCount > 0 && pDeviceConfig->mAppProfileStartIndex+pDeviceConfig->mAppProfileCount > nAppProfiles) )
{
throw runtime_error(
MAKE_STRING(

@ -20,8 +20,8 @@ DeviceConfig::DeviceConfig(
for ( int i=0 ; i < nAppProfiles ; ++i )
{
const ApiAppProfile* pAppProfile = pAppProfiles + i ;
// validate the Event index/count
if ( pAppProfile->mEventStartIndex < 0 || (pAppProfile->mEventStartIndex > 0 && pAppProfile->mEventStartIndex >= nEvents) )
// validate the Event start index and count
if ( pAppProfile->mEventStartIndex < 0 || (pAppProfile->mEventCount > 0 && pAppProfile->mEventStartIndex >= nEvents) )
{
throw runtime_error(
MAKE_STRING(
@ -30,7 +30,7 @@ DeviceConfig::DeviceConfig(
)
) ;
}
if ( pAppProfile->mEventCount < 0 || pAppProfile->mEventStartIndex + pAppProfile->mEventCount > nEvents )
if ( pAppProfile->mEventCount < 0 || (pAppProfile->mEventCount > 0 && pAppProfile->mEventStartIndex+pAppProfile->mEventCount > nEvents) )
{
throw runtime_error(
MAKE_STRING(

Loading…
Cancel
Save