Fixed svace 15/63715/2
authorjunkyu Han <junkyu.han@samsung.com>
Fri, 25 Mar 2016 09:17:27 +0000 (18:17 +0900)
committerjunkyu Han <junkyu.han@samsung.com>
Mon, 28 Mar 2016 02:49:50 +0000 (11:49 +0900)
Change-Id: I0dad120b93a71b22e240631e3a23dc4ddf787768

daemon/icon.c
daemon/main.c
daemon/ticker.c
modules/clock/clock.c
modules/information/alarm.c
modules/information/mp3_playing.c
modules/processing/downloading.c
modules/processing/uploading.c
modules/setting/silent.c

index 3f4cc11..692d36e 100644 (file)
@@ -80,7 +80,7 @@ static Eina_Bool _animate_on_timer_cb(void *data)
        retv_if(!img_edje, ECORE_CALLBACK_CANCEL);
 
        char signal_to_emit[32] = {'\0',};
-       sprintf(signal_to_emit,icon->signal_to_emit_prefix,icon->animation_state);
+       snprintf(signal_to_emit, sizeof(signal_to_emit), icon->signal_to_emit_prefix,icon->animation_state);
 
        edje_object_signal_emit(img_edje, signal_to_emit,"prog");
 
index 4d42129..4e8712b 100644 (file)
@@ -158,7 +158,7 @@ static void _indicator_notify_pm_state_cb(keynode_t * node, void *data)
                        nIndex = 1;
                {
                        char temp[30] = {0,};
-                       sprintf(temp,"indicator.padding.resize.%d",nMove);
+                       snprintf(temp,sizeof(temp), "indicator.padding.resize.%d",nMove);
                        util_signal_emit(data,temp,"indicator.prog");
                }
                icon_set_update_flag(0);
@@ -617,7 +617,7 @@ static void _create_layout(struct appdata *ad, const char *file, const char *gro
        if (EINA_FALSE == elm_layout_file_set(ad->win.layout, file, group)) {
                _E("Failed to set file of layout");
                evas_object_del(ad->win.layout);
-               return NULL;
+               return;
        }
 
        evas_object_size_hint_min_set(ad->win.layout, ad->win.w, ad->win.h);
@@ -1047,6 +1047,7 @@ static bool app_create(void *data)
 {
        struct appdata *ad = data;
        int ret;
+       char buf[256];
 
        retv_if(!ad, false);
 
@@ -1060,15 +1061,15 @@ static bool app_create(void *data)
 
        ret = sigemptyset(&act.sa_mask);
        if (ret < 0) {
-               _E("Failed to sigemptyset[%s]", strerror(errno));
+               _E("Failed to sigemptyset[%s]", strerror_r(errno, buf, sizeof(buf)));
        }
        ret = sigaddset(&act.sa_mask, SIGTERM);
        if (ret < 0) {
-               _E("Failed to sigaddset[%s]", strerror(errno));
+               _E("Failed to sigaddset[%s]", strerror_r(errno, buf, sizeof(buf)));
        }
        ret = sigaction(SIGTERM, &act, NULL);
        if (ret < 0) {
-               _E("Failed to sigaction[%s]", strerror(errno));
+               _E("Failed to sigaction[%s]", strerror_r(errno, buf, sizeof(buf)));
        }
 
        ret = _start_indicator(ad);
index 51b84d3..1d9052c 100644 (file)
@@ -619,12 +619,15 @@ static char *_ticker_get_label_layout_default(notification_h noti, int is_screen
                                        *str_line1 = strdup(tmp);
                                }
                        }
-
-                       eina_strbuf_free(line1);
-                       eina_strbuf_free(line2);
                } else {
                        _E("failed to allocate string buffer");
                }
+               if (line1 != NULL) {
+                       eina_strbuf_free(line1);
+               }
+               if (line2 != NULL) {
+                       eina_strbuf_free(line2);
+               }
        } else {
                if (title_utf8 == NULL
                                && event_count_utf8 == NULL
@@ -749,11 +752,15 @@ static char *_ticker_get_label_layout_single(notification_h noti, int is_screenr
                                }
                        }
 
-                       eina_strbuf_free(line1);
-                       eina_strbuf_free(line2);
                } else {
                        _E("failed to allocate string buffer");
                }
+               if (line1 != NULL) {
+                       eina_strbuf_free(line1);
+               }
+               if (line2 != NULL) {
+                       eina_strbuf_free(line2);
+               }
        } else {
                if (title_utf8 == NULL
                                && content_utf8 == NULL
index 6f4ddd2..27c705f 100644 (file)
@@ -170,7 +170,7 @@ static void indicator_clock_changed_cb(void *data)
 
        /* Set time */
        ctime = time(NULL);
-       ts = localtime(&ctime);
+       localtime_r(&ctime, ts);
        if (ts == NULL) {
                _E("Fail to get localtime !");
                return;
@@ -423,7 +423,7 @@ static int register_clock_module(void *data)
 
 static int unregister_clock_module(void)
 {
-       int ret;
+       int ret = 0;
 
        //ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED);
        ret = ret | vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT_TIME1224, regionformat_changed);
@@ -467,6 +467,8 @@ static char *_string_replacer(const char *src, const char *pattern, const char *
        int idx = 0;
        int out_idx = 0;
        int out_sz = 0;
+       int replace_len = 0;
+
        enum {
                STATE_START,
                STATE_FIND,
@@ -484,6 +486,12 @@ static char *_string_replacer(const char *src, const char *pattern, const char *
                return NULL;
        }
 
+       replace_len = strlen(replace);
+       if (replace_len) {
+               ERR("Ratio");
+               return NULL;
+       }
+
        out_idx = 0;
        for (state = STATE_START, ptr = src; state != STATE_END; ptr++) {
                switch (state) {
@@ -521,7 +529,7 @@ static char *_string_replacer(const char *src, const char *pattern, const char *
      * If there is no space for copying the replacement,
      * Extend size of the return buffer.
      */
-                               if (out_sz - out_idx < strlen(replace) + 1) {
+                               if (out_sz - out_idx < replace_len + 1) {
                                        tmp = _extend_heap(ret, &out_sz, strlen(replace) + 1);
                                        if (!tmp) {
                                                free(ret);
@@ -530,7 +538,7 @@ static char *_string_replacer(const char *src, const char *pattern, const char *
                                        ret = tmp;
                                }
 
-                               strcpy(ret + out_idx, replace);
+                               strncpy(ret + out_idx, replace, replace_len);
                                out_idx += strlen(replace);
 
                                state = STATE_FIND;
@@ -693,11 +701,11 @@ void indicator_get_time_by_region(char* output,void *data)
 
        if(clock_mode == INDICATOR_CLOCK_MODE_12H)
        {
-               strcpy(time_skeleton,"hm");
+               strncpy(time_skeleton,"hm", 2);
        }
        else
        {
-               strcpy(time_skeleton,"Hm");
+               strncpy(time_skeleton,"Hm", 2);
        }
        char* timezone_id = NULL;
        timezone_id = util_get_timezone_str();
@@ -731,9 +739,10 @@ void indicator_get_time_by_region(char* output,void *data)
                                    bestPatternCapacity, &status);
 
        char a_best_pattern[64] = {0,};
+       char *last_pattern = NULL;
        u_austrcpy(a_best_pattern, bestPattern);
-       char *a_best_pattern_fixed = strtok(a_best_pattern, "a");
-       a_best_pattern_fixed = strtok(a_best_pattern_fixed, " ");
+       char *a_best_pattern_fixed = strtok_r(a_best_pattern, "a", &last_pattern);
+       a_best_pattern_fixed = strtok_r(a_best_pattern_fixed, " ", &last_pattern);
        if(a_best_pattern_fixed)
        {
                u_uastrcpy(bestPattern, a_best_pattern_fixed);
index 286e000..8df8d0c 100644 (file)
@@ -147,11 +147,6 @@ static int register_alarm_module(void *data)
        retif(data == NULL, FAIL, "Invalid parameter!");
 
        set_app_state(data);
-       if (ret < 0)
-       {
-               ERR("Fail to init alarmdb.");
-               return FAIL;
-       }
 
        ret = vconf_notify_key_changed(VCONFKEY_ALARM_STATE,
                                        indicator_alarm_change_cb, data);
index 119ddf9..89fd543 100644 (file)
@@ -108,7 +108,13 @@ static void show_mp_icon(void* data)
        FILE* fp = fopen(MUSIC_STATUS_FILE_PATH, "r");
        char line[MAX_NAM_LEN+1];
 
-       retif(data == NULL, , "Invalid parameter!");
+       if (data == NULL) {
+               ERR("Invalid parameter");
+               if (fp) {
+                       fclose(fp);
+               }
+               return;
+       }
        if(fp == NULL)
        {
                ERR("Invalid file path !!");
index e7bb37a..9c3a09e 100644 (file)
@@ -83,9 +83,12 @@ static void hide_image_icon(void)
 
 static Eina_Bool show_downloading_icon_cb(void* data)
 {
+       int possible_index = 0;
 
        show_image_icon(data,icon_index);
-       icon_index = (++icon_index % ICON_NUM) ? icon_index : 0;
+       possible_index = ++icon_index % ICON_NUM;
+
+       icon_index = possible_index ? icon_index : 0;
 
        return ECORE_CALLBACK_RENEW;
 }
@@ -135,12 +138,13 @@ static void indicator_downloading_change_cb(keynode_t *node, void *data)
                ERR("Error getting VCONFKEY_WIFI_DIRECT_RECEIVING_STATE value");
        }*/
 
-       if (result == 1) {
+/*     if (result == 1) {
                show_downloading_icon(data);
 
        } else {
                hide_downloading_icon();
-       }
+       }*/
+       hide_downloading_icon();
 }
 
 static void indicator_downloading_pm_state_change_cb(keynode_t *node, void *data)
index e31ebb3..2fc05c1 100644 (file)
@@ -84,8 +84,12 @@ static void hide_image_icon(void)
 static Eina_Bool show_uploading_icon_cb(void* data)
 {
 
+       int possible_index = 0;
+
        show_image_icon(data,icon_index);
-       icon_index = (++icon_index % ICON_NUM) ? icon_index : 0;
+       possible_index = ++icon_index % ICON_NUM;
+
+       icon_index = possible_index ? icon_index : 0;
 
        return ECORE_CALLBACK_RENEW;
 }
@@ -135,12 +139,13 @@ static void indicator_uploading_change_cb(keynode_t *node, void *data)
                ERR("Failed to get VCONFKEY_WIFI_DIRECT_SENDING_STATE value");
        }*/
 
-       if (result == 1) {
+/*     if (result == 1) {
                show_uploading_icon(data);
 
        } else {
                hide_uploading_icon();
-       }
+       }*/
+       hide_uploading_icon();
 }
 
 static void indicator_uploading_pm_state_change_cb(keynode_t *node, void *data)
index 88bb7b0..9b26b51 100644 (file)
@@ -232,7 +232,7 @@ static int register_silent_module(void *data)
 
 static int unregister_silent_module(void)
 {
-       int ret;
+       int ret = 0;
 
 //     ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE);
        ret = ret | vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, _silent_change_cb);