diff options
author | MyungJoo Ham <myungjoo.ham@samsung.com> | 2013-04-22 18:02:55 +0900 |
---|---|---|
committer | jy910.yun <jy910.yun@samsung.com> | 2013-06-27 14:17:57 +0900 |
commit | 629a28dde90c0a7af08b5fe3f1694387f0bb0e0a (patch) | |
tree | 4e783e85515ac35f94afbfb3a88cf343ba440ebe | |
parent | 915b1cd09ca95f0cce65344819e98dff11647034 (diff) | |
download | device-manager-plugin-pinetrail-2.2_release.tar.gz device-manager-plugin-pinetrail-2.2_release.tar.bz2 device-manager-plugin-pinetrail-2.2_release.zip |
Prevent Error Correction: TAINTED_SCALAR (CID 49051).submit/tizen_2.2/20130714.144623submit/tizen_2.2/20130714.1359432.2_release2.2.1_releasetizen_2.2
There is a possibility that the function may incur divide-by-zero error
with charge_full == 0.
And other case of prevent issue also resolved regarding
uncheck the return value or error handling
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Change-Id: I33ae5ca032927869905dee4ad7266d81e480decb
-rw-r--r-- | src/device_manager_plugin_pinetrail.c | 2 | ||||
-rw-r--r-- | src/test/slp_plugin_test.c | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/device_manager_plugin_pinetrail.c b/src/device_manager_plugin_pinetrail.c index 70214d8..9030981 100644 --- a/src/device_manager_plugin_pinetrail.c +++ b/src/device_manager_plugin_pinetrail.c @@ -704,7 +704,7 @@ int OEM_sys_get_battery_capacity(int *value) if(charge_full == 0) { ret = sys_get_int(BATTERY_CHARGE_FULL_PATH, &charge_full); - if(ret != 0) + if(ret != 0 || charge_full == 0) { devmgr_log("get battery charge full error!"); charge_full = 0; diff --git a/src/test/slp_plugin_test.c b/src/test/slp_plugin_test.c index 90eab44..c916e0b 100644 --- a/src/test/slp_plugin_test.c +++ b/src/test/slp_plugin_test.c @@ -77,6 +77,7 @@ int test_set_level() case 0 ... 100: TEST_SET(OEM_sys_set_haptic_motor_level, level); printf("set level: %d\n", level); + break; case -1: return 0; default: @@ -148,6 +149,7 @@ void svi_test() void vib_test() { char input,tmp; + int r; while(1) { printf("=======================1. vib_test==========================\n"); @@ -159,7 +161,10 @@ void vib_test() printf("q : quit\n"); printf("============================================================\n"); - scanf("%c", &input); + r = scanf("%c", &input); + if (r < 1) + continue; + while((tmp = getchar()) != '\n'); switch(input) { @@ -283,6 +288,7 @@ void backlight_test() int main() { char input,tmp; + int r; OEM_sys_get_devman_plugin_interface(); @@ -298,7 +304,10 @@ int main() printf("q : quit\n"); printf("=====================================================================\n"); - scanf("%c", &input); + r = scanf("%c", &input); + if (r < 1) + continue; + while((tmp = getchar()) != '\n'); switch(input) { |