From: Wei Liu Date: Thu, 23 Jul 2015 07:59:02 +0000 (+0100) Subject: libxl: use thread-safe localtime_r and handle NULL X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2695 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=aba1db82f5f4ebe9d63dbb940abc8e25e5c29489;p=xen.git libxl: use thread-safe localtime_r and handle NULL Signed-off-by: Wei Liu Acked-by: Ian Campbell --- diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c index b3cf3e238a..b379e09b20 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -306,10 +306,16 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config, 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; } @@ -335,6 +341,7 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config, } } +out: return ret; }