提交 f54c556c 编写于 作者: G Gleb Natapov 提交者: Anthony Liguori

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: NGleb Natapov <gleb@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 47113ab6
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册