Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
rtc_timeoffset = d_config->b_info.rtc_timeoffset;
if (libxl_defbool_val(d_config->b_info.localtime)) {
time_t t;
- struct tm *tm;
+ struct tm *tm, result;
t = time(NULL);
- tm = localtime(&t);
+ tm = localtime_r(&t, &result);
+
+ if (!tm) {
+ LOGE(ERROR, "Failed to call localtime_r");
+ ret = ERROR_FAIL;
+ goto out;
+ }
rtc_timeoffset += tm->tm_gmtoff;
}
}
}
+out:
return ret;
}