summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadoslaw Czerski <r.czerski@samsung.com>2016-04-12 18:10:13 +0200
committerRadoslaw Czerski <r.czerski@samsung.com>2016-04-12 18:10:13 +0200
commit3412e2cfc145e7bc5d7d19368023564016215fcf (patch)
tree28e9289dc2bff13d4e2dc87444f63cf6530e5e11
parentbec551c7453661faad6cbccc0455c1c37c63bf8d (diff)
downloadindicator-win-3412e2cfc145e7bc5d7d19368023564016215fcf.tar.gz
indicator-win-3412e2cfc145e7bc5d7d19368023564016215fcf.tar.bz2
indicator-win-3412e2cfc145e7bc5d7d19368023564016215fcf.zip
modules/clock: Use of vulnerable function fixed.
localetime -> localetime_r Change-Id: Icd77548776d1ba5b4f15c79b6c1aa0119b83fc86 Signed-off-by: Radoslaw Czerski <r.czerski@samsung.com>
-rw-r--r--src/modules/clock/clock.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/modules/clock/clock.c b/src/modules/clock/clock.c
index d8c1472..f7a70ec 100644
--- a/src/modules/clock/clock.c
+++ b/src/modules/clock/clock.c
@@ -163,7 +163,7 @@ static void indicator_clock_changed_cb(void *data)
char result[CLOCK_STR_LEN] = {0,};
char icu_apm[CLOCK_STR_LEN] = {0,};
- struct tm *ts = NULL;
+ struct tm ts;
time_t ctime;
struct appdata *ad = NULL;
int len;
@@ -178,8 +178,10 @@ static void indicator_clock_changed_cb(void *data)
/* Set time */
ctime = time(NULL);
- ts = localtime(&ctime);
- if (ts == NULL) {
+
+ errno = 0;
+ localtime_r(&ctime, &ts);
+ if (errno != 0) {
_E("Fail to get localtime !");
return;
}
@@ -195,7 +197,7 @@ static void indicator_clock_changed_cb(void *data)
memset(ampm_buf, 0x00, sizeof(ampm_buf));
memset(buf, 0x00, sizeof(buf));
- clock_timer = ecore_timer_add(60 - ts->tm_sec, (void *)indicator_clock_changed_cb, data);
+ clock_timer = ecore_timer_add(60 - ts.tm_sec, (void *)indicator_clock_changed_cb, data);
if(!clock_timer) {
_E("Fail to add timer !");
}
@@ -210,7 +212,7 @@ static void indicator_clock_changed_cb(void *data)
static int pre_hour = 0;
if (apm_length>=4) {
- if (ts->tm_hour >= 0 && ts->tm_hour < 12) {
+ if (ts.tm_hour >= 0 && ts.tm_hour < 12) {
snprintf(ampm_buf, sizeof(ampm_buf),"%s","AM");
} else {
snprintf(ampm_buf, sizeof(ampm_buf),"%s","PM");
@@ -219,9 +221,9 @@ static void indicator_clock_changed_cb(void *data)
snprintf(ampm_buf, sizeof(ampm_buf),"%s",icu_apm);
}
- strftime(bf1, sizeof(bf1), "%l", ts);
+ strftime(bf1, sizeof(bf1), "%l", &ts);
hour = atoi(bf1);
- strftime(bf1, sizeof(bf1), ":%M", ts);
+ strftime(bf1, sizeof(bf1), ":%M", &ts);
font_size = TIME_FONT_SIZE_12;
clock_hour = hour;