From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=ting.ye@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 969802116DF97 for ; Wed, 17 Oct 2018 20:03:34 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2018 20:03:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,393,1534834800"; d="scan'208";a="82099134" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga007.jf.intel.com with ESMTP; 17 Oct 2018 20:03:34 -0700 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 17 Oct 2018 20:03:34 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 17 Oct 2018 20:03:33 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.111]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.183]) with mapi id 14.03.0319.002; Thu, 18 Oct 2018 11:03:31 +0800 From: "Ye, Ting" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" Thread-Topic: [Patch] NetworkPkg: Correct the time stamp and fix the integer overflow issue. Thread-Index: AQHUZRI2WnjI6X1OaEy6JN0GTaD8U6UkVBXQ Date: Thu, 18 Oct 2018 03:03:31 +0000 Message-ID: References: <20181016053609.704-1-Jiaxin.wu@intel.com> In-Reply-To: <20181016053609.704-1-Jiaxin.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] NetworkPkg: Correct the time stamp and fix the integer overflow issue. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Oct 2018 03:03:34 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ye Ting =20 -----Original Message----- From: Wu, Jiaxin=20 Sent: Tuesday, October 16, 2018 1:36 PM To: edk2-devel@lists.01.org Cc: Fu, Siyuan ; Ye, Ting ; Wu, Jia= xin Subject: [Patch] NetworkPkg: Correct the time stamp and fix the integer ove= rflow issue. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D883. Cc: Fu Siyuan Cc: Ye Ting Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wu Jiaxin --- NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c | 18 +++++++++--------- NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c b/NetworkPkg/Dhcp6Dxe/Dhcp6= Utility.c index 10a99a00d4..9c7459c332 100644 --- a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c +++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c @@ -121,11 +121,11 @@ Dhcp6GenerateClientId ( // Generate a time stamp of the seconds from 2000/1/1, assume 30day/mo= nth. // gRT->GetTime (&Time, NULL); Stamp =3D (UINT32) ( - (((((Time.Year - 2000) * 360 + (Time.Month - 1)) * 30 + (Time.Day = - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * + ((((UINT32)(Time.Year - 2000) * 360 + (Time.Month - 1) * 30 + (Tim= e.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * 60 + Time.Second ); =20 // @@ -879,18 +879,18 @@ SetElapsedTime ( =20 // // Generate a time stamp of the centiseconds from 2000/1/1, assume 30day= /month. // gRT->GetTime (&Time, NULL); - CurrentStamp =3D (UINT64) - ( - ((((((Time.Year - 2000) * 360 + - (Time.Month - 1)) * 30 + - (Time.Day - 1)) * 24 + Time.Hour) * 60 + - Time.Minute) * 60 + Time.Second) * 100 - + DivU64x32(Time.Nanosecond, 10000000) - ); + CurrentStamp =3D MultU64x32 ( + ((((UINT32)(Time.Year - 2000) * 360 + (Time.Month - 1) = * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * 60 + Time.Se= cond, + 100 + ) + + DivU64x32( + Time.Nanosecond, + 10000000 + ); =20 // // Sentinel value of 0 means that this is the first DHCP packet that we = are // sending and that we need to initialize the value. First DHCP message // gets 0 elapsed-time. Otherwise, calculate based on StartTime. diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c b/NetworkPkg/UefiPxeBcD= xe/PxeBcSupport.c index 60509fc9e6..7ab09e0367 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c @@ -1508,18 +1508,18 @@ CalcElapsedTime ( // // Generate a time stamp of the centiseconds from 1900/1/1, assume 30day= /month. // ZeroMem (&Time, sizeof (EFI_TIME)); gRT->GetTime (&Time, NULL); - CurrentStamp =3D (UINT64) - ( - ((((((Time.Year - 1900) * 360 + - (Time.Month - 1)) * 30 + - (Time.Day - 1)) * 24 + Time.Hour) * 60 + - Time.Minute) * 60 + Time.Second) * 100 - + DivU64x32(Time.Nanosecond, 10000000) - ); + CurrentStamp =3D MultU64x32 ( + ((((UINT32)(Time.Year - 1900) * 360 + (Time.Month - 1) = * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * 60 + Time.Se= cond, + 100 + ) + + DivU64x32 ( + Time.Nanosecond, + 10000000 + ); =20 // // Sentinel value of 0 means that this is the first DHCP packet that we = are // sending and that we need to initialize the value. First DHCP Solicit // gets 0 elapsed-time. Otherwise, calculate based on StartTime. --=20 2.17.1.windows.2