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.20; helo=mga02.intel.com; envelope-from=qin.long@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 743842234433E for ; Thu, 18 Jan 2018 23:16:11 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2018 23:21:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,380,1511856000"; d="scan'208";a="10956967" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga007.jf.intel.com with ESMTP; 18 Jan 2018 23:21:33 -0800 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 18 Jan 2018 23:21:32 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 18 Jan 2018 23:21:32 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Fri, 19 Jan 2018 15:21:30 +0800 From: "Long, Qin" To: "Ni, Ruiyu" , "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Zeng, Star" Thread-Topic: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper Thread-Index: AQHTkPPs/ZoMlNIjQUmEovUbs4Frz6N6QSGAgACGLmD//3rlAIAAAHaAgACHZKA= Date: Fri, 19 Jan 2018 07:21:30 +0000 Message-ID: References: <20180119070506.5980-1-qin.long@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B9FED1E@shsmsx102.ccr.corp.intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B9FED3B@shsmsx102.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5BB36F7D@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5BB36F7D@SHSMSX104.ccr.corp.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] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jan 2018 07:16:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Yes, and the function comment were already there. -----Original Message----- From: Ni, Ruiyu=20 Sent: Friday, January 19, 2018 3:16 PM To: Zeng, Star ; Long, Qin ; edk2-= devel@lists.01.org Cc: Ye, Ting ; Zeng, Star Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() = wrapper Qin, How about add more comments to say the tick is calculated from 1970 first s= econd? Thanks/Ray > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of=20 > Zeng, Star > Sent: Friday, January 19, 2018 3:14 PM > To: Long, Qin ; edk2-devel@lists.01.org > Cc: Ye, Ting ; Zeng, Star > Subject: Re: [edk2] [PATCH] CryptoPkg/BaseCryptLib: Add error handling=20 > for > time() wrapper >=20 > Ok, got it. >=20 > Reviewed-by: Star Zeng >=20 > Thanks, > Star > -----Original Message----- > From: Long, Qin > Sent: Friday, January 19, 2018 3:12 PM > To: Zeng, Star ; edk2-devel@lists.01.org > Cc: Ye, Ting > Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for=20 > time() wrapper >=20 > It's legal to continue the calculation about the seconds elapsed since > 1970.01.01 00:00:00. >=20 >=20 > -----Original Message----- > From: Zeng, Star > Sent: Friday, January 19, 2018 3:10 PM > To: Long, Qin ; edk2-devel@lists.01.org > Cc: Ye, Ting ; Zeng, Star > Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for=20 > time() wrapper >=20 > What will happen if Time.Year =3D=3D 1970? :) >=20 > Thanks, > Star > -----Original Message----- > From: Long, Qin > Sent: Friday, January 19, 2018 3:05 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Ye, Ting ;=20 > Long, Qin > Subject: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time()=20 > wrapper >=20 > In time() wrapper implementation, the gRT->GetTime() call may be not=20 > available. This patch adds the extra error handling to avoid the=20 > potential dead loop. >=20 > Cc: Star Zeng > Cc: Ting Ye > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Qin Long > --- > CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 12=20 > ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) >=20 > diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c > b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c > index 581b8fb028..95e0419640 100644 > --- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c > +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c > @@ -72,14 +72,18 @@ UINTN CumulativeDays[2][14] =3D { // ) time_t=20 > time (time_t *timer) { > - EFI_TIME Time; > - time_t CalTime; > - UINTN Year; > + EFI_STATUS Status; > + EFI_TIME Time; > + time_t CalTime; > + UINTN Year; >=20 > // > // Get the current time and date information > // > - gRT->GetTime (&Time, NULL); > + Status =3D gRT->GetTime (&Time, NULL); if (EFI_ERROR (Status) ||=20 > + (Time.Year < 1970)) { > + return 0; > + } >=20 > // > // Years Handling > -- > 2.15.1.windows.2 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel