* [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper @ 2018-01-19 7:05 Long Qin 2018-01-19 7:10 ` Zeng, Star 0 siblings, 1 reply; 6+ messages in thread From: Long Qin @ 2018-01-19 7:05 UTC (permalink / raw) To: edk2-devel; +Cc: star.zeng, ting.ye, Qin Long In time() wrapper implementation, the gRT->GetTime() call may be not available. This patch adds the extra error handling to avoid the potential dead loop. Cc: Star Zeng <star.zeng@intel.com> Cc: Ting Ye <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> --- CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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] = { // ) time_t time (time_t *timer) { - EFI_TIME Time; - time_t CalTime; - UINTN Year; + EFI_STATUS Status; + EFI_TIME Time; + time_t CalTime; + UINTN Year; // // Get the current time and date information // - gRT->GetTime (&Time, NULL); + Status = gRT->GetTime (&Time, NULL); + if (EFI_ERROR (Status) || (Time.Year < 1970)) { + return 0; + } // // Years Handling -- 2.15.1.windows.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper 2018-01-19 7:05 [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper Long Qin @ 2018-01-19 7:10 ` Zeng, Star 2018-01-19 7:12 ` Long, Qin 0 siblings, 1 reply; 6+ messages in thread From: Zeng, Star @ 2018-01-19 7:10 UTC (permalink / raw) To: Long, Qin, edk2-devel@lists.01.org; +Cc: Ye, Ting, Zeng, Star What will happen if Time.Year == 1970? :) Thanks, Star -----Original Message----- From: Long, Qin Sent: Friday, January 19, 2018 3:05 PM To: edk2-devel@lists.01.org Cc: Zeng, Star <star.zeng@intel.com>; Ye, Ting <ting.ye@intel.com>; Long, Qin <qin.long@intel.com> Subject: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper In time() wrapper implementation, the gRT->GetTime() call may be not available. This patch adds the extra error handling to avoid the potential dead loop. Cc: Star Zeng <star.zeng@intel.com> Cc: Ting Ye <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> --- CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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] = { // ) time_t time (time_t *timer) { - EFI_TIME Time; - time_t CalTime; - UINTN Year; + EFI_STATUS Status; + EFI_TIME Time; + time_t CalTime; + UINTN Year; // // Get the current time and date information // - gRT->GetTime (&Time, NULL); + Status = gRT->GetTime (&Time, NULL); + if (EFI_ERROR (Status) || (Time.Year < 1970)) { + return 0; + } // // Years Handling -- 2.15.1.windows.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper 2018-01-19 7:10 ` Zeng, Star @ 2018-01-19 7:12 ` Long, Qin 2018-01-19 7:14 ` Zeng, Star 0 siblings, 1 reply; 6+ messages in thread From: Long, Qin @ 2018-01-19 7:12 UTC (permalink / raw) To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Ye, Ting It's legal to continue the calculation about the seconds elapsed since 1970.01.01 00:00:00. -----Original Message----- From: Zeng, Star Sent: Friday, January 19, 2018 3:10 PM To: Long, Qin <qin.long@intel.com>; edk2-devel@lists.01.org Cc: Ye, Ting <ting.ye@intel.com>; Zeng, Star <star.zeng@intel.com> Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper What will happen if Time.Year == 1970? :) Thanks, Star -----Original Message----- From: Long, Qin Sent: Friday, January 19, 2018 3:05 PM To: edk2-devel@lists.01.org Cc: Zeng, Star <star.zeng@intel.com>; Ye, Ting <ting.ye@intel.com>; Long, Qin <qin.long@intel.com> Subject: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper In time() wrapper implementation, the gRT->GetTime() call may be not available. This patch adds the extra error handling to avoid the potential dead loop. Cc: Star Zeng <star.zeng@intel.com> Cc: Ting Ye <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> --- CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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] = { // ) time_t time (time_t *timer) { - EFI_TIME Time; - time_t CalTime; - UINTN Year; + EFI_STATUS Status; + EFI_TIME Time; + time_t CalTime; + UINTN Year; // // Get the current time and date information // - gRT->GetTime (&Time, NULL); + Status = gRT->GetTime (&Time, NULL); + if (EFI_ERROR (Status) || (Time.Year < 1970)) { + return 0; + } // // Years Handling -- 2.15.1.windows.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper 2018-01-19 7:12 ` Long, Qin @ 2018-01-19 7:14 ` Zeng, Star 2018-01-19 7:15 ` Ni, Ruiyu 0 siblings, 1 reply; 6+ messages in thread From: Zeng, Star @ 2018-01-19 7:14 UTC (permalink / raw) To: Long, Qin, edk2-devel@lists.01.org; +Cc: Ye, Ting, Zeng, Star Ok, got it. Reviewed-by: Star Zeng <star.zeng@intel.com> Thanks, Star -----Original Message----- From: Long, Qin Sent: Friday, January 19, 2018 3:12 PM To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org Cc: Ye, Ting <ting.ye@intel.com> Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper It's legal to continue the calculation about the seconds elapsed since 1970.01.01 00:00:00. -----Original Message----- From: Zeng, Star Sent: Friday, January 19, 2018 3:10 PM To: Long, Qin <qin.long@intel.com>; edk2-devel@lists.01.org Cc: Ye, Ting <ting.ye@intel.com>; Zeng, Star <star.zeng@intel.com> Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper What will happen if Time.Year == 1970? :) Thanks, Star -----Original Message----- From: Long, Qin Sent: Friday, January 19, 2018 3:05 PM To: edk2-devel@lists.01.org Cc: Zeng, Star <star.zeng@intel.com>; Ye, Ting <ting.ye@intel.com>; Long, Qin <qin.long@intel.com> Subject: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper In time() wrapper implementation, the gRT->GetTime() call may be not available. This patch adds the extra error handling to avoid the potential dead loop. Cc: Star Zeng <star.zeng@intel.com> Cc: Ting Ye <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> --- CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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] = { // ) time_t time (time_t *timer) { - EFI_TIME Time; - time_t CalTime; - UINTN Year; + EFI_STATUS Status; + EFI_TIME Time; + time_t CalTime; + UINTN Year; // // Get the current time and date information // - gRT->GetTime (&Time, NULL); + Status = gRT->GetTime (&Time, NULL); + if (EFI_ERROR (Status) || (Time.Year < 1970)) { + return 0; + } // // Years Handling -- 2.15.1.windows.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper 2018-01-19 7:14 ` Zeng, Star @ 2018-01-19 7:15 ` Ni, Ruiyu 2018-01-19 7:21 ` Long, Qin 0 siblings, 1 reply; 6+ messages in thread From: Ni, Ruiyu @ 2018-01-19 7:15 UTC (permalink / raw) To: Zeng, Star, Long, Qin, edk2-devel@lists.01.org; +Cc: Ye, Ting, Zeng, Star Qin, How about add more comments to say the tick is calculated from 1970 first second? Thanks/Ray > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Zeng, Star > Sent: Friday, January 19, 2018 3:14 PM > To: Long, Qin <qin.long@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com>; Zeng, Star <star.zeng@intel.com> > Subject: Re: [edk2] [PATCH] CryptoPkg/BaseCryptLib: Add error handling for > time() wrapper > > Ok, got it. > > Reviewed-by: Star Zeng <star.zeng@intel.com> > > Thanks, > Star > -----Original Message----- > From: Long, Qin > Sent: Friday, January 19, 2018 3:12 PM > To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com> > Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() > wrapper > > It's legal to continue the calculation about the seconds elapsed since > 1970.01.01 00:00:00. > > > -----Original Message----- > From: Zeng, Star > Sent: Friday, January 19, 2018 3:10 PM > To: Long, Qin <qin.long@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com>; Zeng, Star <star.zeng@intel.com> > Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() > wrapper > > What will happen if Time.Year == 1970? :) > > Thanks, > Star > -----Original Message----- > From: Long, Qin > Sent: Friday, January 19, 2018 3:05 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star <star.zeng@intel.com>; Ye, Ting <ting.ye@intel.com>; Long, > Qin <qin.long@intel.com> > Subject: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() > wrapper > > In time() wrapper implementation, the gRT->GetTime() call may be not > available. This patch adds the extra error handling to avoid the potential dead > loop. > > Cc: Star Zeng <star.zeng@intel.com> > Cc: Ting Ye <ting.ye@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Qin Long <qin.long@intel.com> > --- > CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > 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] = { // ) time_t time > (time_t *timer) { > - EFI_TIME Time; > - time_t CalTime; > - UINTN Year; > + EFI_STATUS Status; > + EFI_TIME Time; > + time_t CalTime; > + UINTN Year; > > // > // Get the current time and date information > // > - gRT->GetTime (&Time, NULL); > + Status = gRT->GetTime (&Time, NULL); > + if (EFI_ERROR (Status) || (Time.Year < 1970)) { > + return 0; > + } > > // > // Years Handling > -- > 2.15.1.windows.2 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper 2018-01-19 7:15 ` Ni, Ruiyu @ 2018-01-19 7:21 ` Long, Qin 0 siblings, 0 replies; 6+ messages in thread From: Long, Qin @ 2018-01-19 7:21 UTC (permalink / raw) To: Ni, Ruiyu, Zeng, Star, edk2-devel@lists.01.org; +Cc: Ye, Ting, Zeng, Star Yes, and the function comment were already there. -----Original Message----- From: Ni, Ruiyu Sent: Friday, January 19, 2018 3:16 PM To: Zeng, Star <star.zeng@intel.com>; Long, Qin <qin.long@intel.com>; edk2-devel@lists.01.org Cc: Ye, Ting <ting.ye@intel.com>; Zeng, Star <star.zeng@intel.com> 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 second? Thanks/Ray > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Zeng, Star > Sent: Friday, January 19, 2018 3:14 PM > To: Long, Qin <qin.long@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com>; Zeng, Star <star.zeng@intel.com> > Subject: Re: [edk2] [PATCH] CryptoPkg/BaseCryptLib: Add error handling > for > time() wrapper > > Ok, got it. > > Reviewed-by: Star Zeng <star.zeng@intel.com> > > Thanks, > Star > -----Original Message----- > From: Long, Qin > Sent: Friday, January 19, 2018 3:12 PM > To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com> > Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for > time() wrapper > > It's legal to continue the calculation about the seconds elapsed since > 1970.01.01 00:00:00. > > > -----Original Message----- > From: Zeng, Star > Sent: Friday, January 19, 2018 3:10 PM > To: Long, Qin <qin.long@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com>; Zeng, Star <star.zeng@intel.com> > Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for > time() wrapper > > What will happen if Time.Year == 1970? :) > > Thanks, > Star > -----Original Message----- > From: Long, Qin > Sent: Friday, January 19, 2018 3:05 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star <star.zeng@intel.com>; Ye, Ting <ting.ye@intel.com>; > Long, Qin <qin.long@intel.com> > Subject: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() > wrapper > > In time() wrapper implementation, the gRT->GetTime() call may be not > available. This patch adds the extra error handling to avoid the > potential dead loop. > > Cc: Star Zeng <star.zeng@intel.com> > Cc: Ting Ye <ting.ye@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Qin Long <qin.long@intel.com> > --- > CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 12 > ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > 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] = { // ) time_t > time (time_t *timer) { > - EFI_TIME Time; > - time_t CalTime; > - UINTN Year; > + EFI_STATUS Status; > + EFI_TIME Time; > + time_t CalTime; > + UINTN Year; > > // > // Get the current time and date information > // > - gRT->GetTime (&Time, NULL); > + Status = gRT->GetTime (&Time, NULL); if (EFI_ERROR (Status) || > + (Time.Year < 1970)) { > + return 0; > + } > > // > // Years Handling > -- > 2.15.1.windows.2 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-01-19 7:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-01-19 7:05 [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() wrapper Long Qin 2018-01-19 7:10 ` Zeng, Star 2018-01-19 7:12 ` Long, Qin 2018-01-19 7:14 ` Zeng, Star 2018-01-19 7:15 ` Ni, Ruiyu 2018-01-19 7:21 ` Long, Qin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox