From 56eb29b9b9b61aef4e915f0aef6ba5f7f11d168d Mon Sep 17 00:00:00 2001 From: Radoslaw Cybulski Date: Thu, 18 Apr 2019 14:27:59 +0200 Subject: [PATCH] Fix SVACE issue with invalid parameter validation Change-Id: I86672c8acd1de073fa3bd7dd7101bcb548b770fd --- src/ScreenSwitchPage.cpp | 2 +- src/UniversalSwitchSettingsPage.cpp | 10 +++++----- src/utils/AccessibilitySettingLog.hpp | 6 ------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/ScreenSwitchPage.cpp b/src/ScreenSwitchPage.cpp index a9b0705..9be6913 100644 --- a/src/ScreenSwitchPage.cpp +++ b/src/ScreenSwitchPage.cpp @@ -40,7 +40,7 @@ void ScreenSwitchPage::actionCb(const std::string &action, void *user_data) if (self->switch_added_cb) { auto switches = setting_accessibility_universal_switch_dbus_config_get_switches( &self->context_.config, ACCESSIBILITY_UNIVERSAL_SWITCH_SCREEN_SWITCH_PROVIDER); - PRINT_ERROR_MESSAGE_IF(switches.size() < 1, "Screen switch not found"); + ASSERT(!switches.empty(), "Screen switch not found"); auto screen_switch = switches[0]; self->switch_added_cb(self->switch_added_cb_data, screen_switch->id, action, ACCESSIBILITY_UNIVERSAL_SWITCH_SCREEN); } diff --git a/src/UniversalSwitchSettingsPage.cpp b/src/UniversalSwitchSettingsPage.cpp index d5e42a1..5973b3c 100644 --- a/src/UniversalSwitchSettingsPage.cpp +++ b/src/UniversalSwitchSettingsPage.cpp @@ -592,7 +592,7 @@ void UniversalSwitchSettingsPage::feedbackVoiceItemOptionsRequestCb(int option_i void UniversalSwitchSettingsPage::feedbackVoiceSpeechVolumeChangedCb(size_t item_id) { - PRINT_ERROR_MESSAGE_IF(item_id >= mediaLevel.size(), "Invalid item_id"); + ASSERT(item_id < mediaLevel.size(), "Invalid item_id"); double media_level = mediaLevel[item_id].second / 100.0; context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_VOICE)->setSecondValue(media_level); @@ -603,7 +603,7 @@ void UniversalSwitchSettingsPage::feedbackVoiceSpeechVolumeChangedCb(size_t item void UniversalSwitchSettingsPage::feedbackVoiceSpeechRateChangedCb(size_t item_id) { - PRINT_ERROR_MESSAGE_IF(item_id >= mediaLevel.size(), "Invalid item_id"); + ASSERT(item_id < mediaLevel.size(), "Invalid item_id"); double media_level = mediaLevel[item_id].second / 100.0; context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_VOICE)->setFirstValue(media_level); @@ -641,7 +641,7 @@ void UniversalSwitchSettingsPage::feedbackSoundItemOptionsRequestCb(int option_i void UniversalSwitchSettingsPage::feedbackSoundVolumeChangedCb(size_t item_id) { - PRINT_ERROR_MESSAGE_IF(item_id >= mediaLevel.size(), "Invalid item_id"); + ASSERT(item_id < mediaLevel.size(), "Invalid item_id"); double media_level = mediaLevel[item_id].second / 100.0; context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_SOUND)->setFirstValue(media_level); @@ -660,7 +660,7 @@ void UniversalSwitchSettingsPage::feedbackSoundSwitchChangedCb(bool state) void UniversalSwitchSettingsPage::cursorColorListItemChangedCb(size_t item_id) { - PRINT_ERROR_MESSAGE_IF(item_id >= cursorColors.size(), "Invalid cursor color id"); + ASSERT(item_id < cursorColors.size(), "Invalid cursor color id"); context_.usScanningProperties.getScanningProperty(Property::CURSOR_COLOR)->setFirstValue(cursorColors[item_id].second); cursorColor_->setDescription(cursorColors[item_id].first); @@ -923,4 +923,4 @@ std::string UniversalSwitchSettingsPage::findCursorColor() } return "Undefined"; -} \ No newline at end of file +} diff --git a/src/utils/AccessibilitySettingLog.hpp b/src/utils/AccessibilitySettingLog.hpp index 0a30f39..b43211b 100644 --- a/src/utils/AccessibilitySettingLog.hpp +++ b/src/utils/AccessibilitySettingLog.hpp @@ -84,12 +84,6 @@ } while (0) #endif -#define PRINT_ERROR_MESSAGE_IF(condition, errorMessage, arg...) \ - do { \ - if (condition) \ - ERROR(errorMessage, ##arg); \ - } while (0) - #define RETURN_IF(condition, errorMessage, arg...) \ do { \ if (condition) { \ -- 2.7.4