Fix SVACE issue with invalid parameter validation 23/204023/1
authorRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Thu, 18 Apr 2019 12:27:59 +0000 (14:27 +0200)
committerRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Thu, 18 Apr 2019 12:27:59 +0000 (14:27 +0200)
Change-Id: I86672c8acd1de073fa3bd7dd7101bcb548b770fd

src/ScreenSwitchPage.cpp
src/UniversalSwitchSettingsPage.cpp
src/utils/AccessibilitySettingLog.hpp

index a9b07056b6af737b0ebd8570e838dc151b22179b..9be691340adedeb33187fd57dec3ec99e7b03b62 100644 (file)
@@ -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);
        }
index d5e42a1f973a57d591fe3e17775cf3982f1ded86..5973b3c19495e9f5ed4865bef2c99931302289d1 100644 (file)
@@ -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<int>(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
+}
index 0a30f39820ff22bae4170c352967ec6381045a8a..b43211ba9e6561c6896c2ed0f996a4f744a7a806 100644 (file)
        } 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) {                           \