From nobody Wed May 8 04:01:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151748649122198.09577605537606; Thu, 1 Feb 2018 04:01:31 -0800 (PST) Received: from localhost ([::1]:59453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehDYY-0005Ix-FC for importer@patchew.org; Thu, 01 Feb 2018 07:01:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehDXK-0004rI-DZ for qemu-devel@nongnu.org; Thu, 01 Feb 2018 07:00:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehDXB-0004wm-72 for qemu-devel@nongnu.org; Thu, 01 Feb 2018 07:00:14 -0500 Received: from [45.249.212.32] (port=43922 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehDXA-0004qY-RT for qemu-devel@nongnu.org; Thu, 01 Feb 2018 07:00:05 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 74FEA7169166E; Thu, 1 Feb 2018 19:59:46 +0800 (CST) Received: from localhost (10.177.18.62) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.361.1; Thu, 1 Feb 2018 19:59:41 +0800 From: Gonglei To: Date: Thu, 1 Feb 2018 19:59:32 +0800 Message-ID: <1517486372-22868-1-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.8.2.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.18.62] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH] vl: fix possible int overflow for qemu_timedate_diff() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Gonglei , shenghualong Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: shenghualong When the Windows guest users set the time to year 2099, the return value of qemu_timedate_diff() will overflow with variable clock mode as below format: Let's change the return value of qemu_timedate_diff() from int to time_t to fix the possible overflow problem. Signed-off-by: shenghualong Signed-off-by: Gonglei --- include/qemu-common.h | 2 +- vl.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index 05319b9..6fb80aa 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -33,7 +33,7 @@ int qemu_main(int argc, char **argv, char **envp); #endif =20 void qemu_get_timedate(struct tm *tm, int offset); -int qemu_timedate_diff(struct tm *tm); +time_t qemu_timedate_diff(struct tm *tm); =20 #define qemu_isalnum(c) isalnum((unsigned char)(c)) #define qemu_isalpha(c) isalpha((unsigned char)(c)) diff --git a/vl.c b/vl.c index e517a8d..9d225da 100644 --- a/vl.c +++ b/vl.c @@ -146,7 +146,7 @@ int nb_nics; NICInfo nd_table[MAX_NICS]; int autostart; static int rtc_utc =3D 1; -static int rtc_date_offset =3D -1; /* -1 means no change */ +static time_t rtc_date_offset =3D -1; /* -1 means no change */ QEMUClockType rtc_clock; int vga_interface_type =3D VGA_NONE; static int full_screen =3D 0; @@ -812,7 +812,7 @@ void qemu_get_timedate(struct tm *tm, int offset) } } =20 -int qemu_timedate_diff(struct tm *tm) +time_t qemu_timedate_diff(struct tm *tm) { time_t seconds; =20 --=20 1.8.3.1