From: Gleb Natapov Date: Sun, 6 Nov 2011 16:00:22 +0000 (+0200) Subject: qemu_timedate_diff() shouldn't modify its argument. X-Git-Tag: qemu-xen-4.2.0~167 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=f54c556c08c57a317ad54f5d2d9ad549b931cda2;p=qemu-upstream-4.2-testing.git qemu_timedate_diff() shouldn't modify its argument. The caller of qemu_timedate_diff() does not expect that tm it passes to the function will be modified, but mktime() is destructive and modifies its argument. Pass a copy of tm to it and set tm_isdst so that mktime() will not rely on it since its value may be outdated. Signed-off-by: Gleb Natapov Signed-off-by: Anthony Liguori --- diff --git a/vl.c b/vl.c index 624da0fd3..641629b1c 100644 --- a/vl.c +++ b/vl.c @@ -460,8 +460,11 @@ int qemu_timedate_diff(struct tm *tm) if (rtc_date_offset == -1) if (rtc_utc) seconds = mktimegm(tm); - else - seconds = mktime(tm); + else { + struct tm tmp = *tm; + tmp.tm_isdst = -1; /* use timezone to figure it out */ + seconds = mktime(&tmp); + } else seconds = mktimegm(tm) + rtc_date_offset;