[Feature] Fixed prevent CID: 441793
localtime replaced with localtime_r
[Verification] Code compiles without errors.
TCT passrate 100%
Change-Id: Icdd66ed81bc07d9cfe295bbe98cbe10586138ddc
Signed-off-by: Piotr Kosko <p.kosko@samsung.com>
static int get_utc_offset() {
LoggerD("Enter");
time_t zero = 24 * 60 * 60L;
- struct tm* timeptr;
+ struct tm time_struct = {0};
int gmtime_hours = 0;
/* get the local time for Jan 2, 1900 00:00 UTC */
- timeptr = localtime(&zero);
- if (nullptr != timeptr) {
- gmtime_hours = timeptr->tm_hour;
+ tzset();
+ if (nullptr != localtime_r(&zero, &time_struct)) {
+ gmtime_hours = time_struct.tm_hour;
- if (timeptr->tm_mday < 2)
+ if (time_struct.tm_mday < 2)
gmtime_hours -= 24;
}
return gmtime_hours;