Call tzset() before localtime_r() 75/231775/1
authorInkyun Kil <inkyun.kil@samsung.com>
Fri, 24 Apr 2020 06:10:08 +0000 (15:10 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Fri, 24 Apr 2020 06:12:17 +0000 (15:12 +0900)
Change-Id: Ie84caf99f43b4d5dc0da5b40c03320cb83fbe7c1
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
lib/alarm-lib.c
server/alarm-manager-db.c
server/alarm-manager-schedule.c
server/alarm-manager-timer.c
server/alarm-manager.c

index fbc18da..f9f1014 100644 (file)
@@ -508,6 +508,7 @@ static void __adjust_current_milliseconds(base_info_t *base_info)
                if (current_time.tv_sec == start) {
                        start += 1;
 
+                       tzset();
                        localtime_r(&start, &start_tm);
                        base_info->start.year = start_tm.tm_year + 1900;
                        base_info->start.month = start_tm.tm_mon + 1;
index 1b63b77..5de09b3 100644 (file)
@@ -489,6 +489,7 @@ int _get_db_path_for_all_info(uid_t uid, char** db_path)
 
        /* Open a DB */
        time(&current_time);
+       tzset();
        localtime_r(&current_time, &current_tm);
        snprintf(db_path_tmp, sizeof(db_path_tmp), "/tmp/alarmmgr_%d%d%d_%02d%02d%02d.db",
                current_tm.tm_year + 1900, current_tm.tm_mon + 1, current_tm.tm_mday, current_tm.tm_hour, current_tm.tm_min, current_tm.tm_sec);
index a4ded97..d89e2c7 100644 (file)
@@ -406,6 +406,7 @@ void _alarm_set_next_duetime(__alarm_info_t *__alarm_info)
        alarm_mode_t *mode = &base_info->mode;
 
        time(&current_time);
+       tzset();
        cur_tm = localtime_r(&current_time, &tm);
        if (cur_tm && cur_tm->tm_isdst > 0)
                is_dst = 1;
index e0e876d..d98640b 100644 (file)
@@ -202,7 +202,7 @@ void _alarm_set_timer(int timer, time_t due_time)
        /*set timer as absolute time */
        /*we create dummy timer when the interval is longer than one day. */
        /*the timer will be expired in half day. */
-
+       tzset();
        localtime_r(&due_time, &ts_ret);
 
        if (interval > 60 * 60 * 24) {
index ebbb90e..f545ed5 100644 (file)
@@ -792,6 +792,7 @@ static bool __alarm_add_and_set(__alarm_info_t *alarm_info, pid_t pid)
                __alarm_add_to_list(alarm_info);
                return true;
        } else {
+               tzset();
                localtime_r(&(alarm_info->due_time), &ts_ret);
                strftime(due_time_r, 30, "%c", &ts_ret);
                SECURE_LOGD("[alarm-server]:Create a new alarm: alarm(%d) due_time(%s)",
@@ -1129,6 +1130,7 @@ static bool __alarm_update(uid_t uid, alarm_id_t alarm_id,
                                __alarm_info->due_time, current_time);
                return true;
        } else {
+               tzset();
                localtime_r(&(__alarm_info->due_time), &ts_ret);
                strftime(due_time_r, 30, "%c", &ts_ret);
                SECURE_LOGD("[alarm-server]:Update alarm: alarm(%d) "
@@ -2503,6 +2505,7 @@ int alarm_manager_alarm_create_periodic(GVariant *parameters, uid_t uid,
 
        struct tm standard_tm;
        time_t standard_time = _get_periodic_alarm_standard_time();
+       tzset();
        localtime_r(&standard_time, &standard_tm);
 
        base_info.reserved_info = standard_time;