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 fbc18dabda6f037ec4c13b13ac57e1800797038f..f9f1014e3f9c8b57a0d452e76b66c78e6f678566 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 1b63b77d260de910efafd05f2a0eccdd5ce01fae..5de09b35381000b3e9c14c738a9b47878680ad2f 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 a4ded97ee4aa5eed855ca11783ae08e21bc25e22..d89e2c72da9c3d0ac77e43615406fc2c872f7a17 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 e0e876d5eb76605442eb1701ee9b99b9e9328d61..d98640bf1b449a4d01c671a8546ade7bdb5c28ba 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 ebbb90e60905df1c65a30243ab55170e8b2dcf48..f545ed5ddd7cb0f68c9d3e7118e36b6184570f1f 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;