NetworkPkg: Correct the time stamp and fix the integer overflow issue.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=883. Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Ye Ting <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com>
This commit is contained in:
@ -123,7 +123,7 @@ Dhcp6GenerateClientId (
|
|||||||
gRT->GetTime (&Time, NULL);
|
gRT->GetTime (&Time, NULL);
|
||||||
Stamp = (UINT32)
|
Stamp = (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 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) *
|
||||||
60 +
|
60 +
|
||||||
Time.Second
|
Time.Second
|
||||||
);
|
);
|
||||||
@ -881,14 +881,14 @@ SetElapsedTime (
|
|||||||
// Generate a time stamp of the centiseconds from 2000/1/1, assume 30day/month.
|
// Generate a time stamp of the centiseconds from 2000/1/1, assume 30day/month.
|
||||||
//
|
//
|
||||||
gRT->GetTime (&Time, NULL);
|
gRT->GetTime (&Time, NULL);
|
||||||
CurrentStamp = (UINT64)
|
CurrentStamp = MultU64x32 (
|
||||||
(
|
((((UINT32)(Time.Year - 2000) * 360 + (Time.Month - 1) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * 60 + Time.Second,
|
||||||
((((((Time.Year - 2000) * 360 +
|
100
|
||||||
(Time.Month - 1)) * 30 +
|
) +
|
||||||
(Time.Day - 1)) * 24 + Time.Hour) * 60 +
|
DivU64x32(
|
||||||
Time.Minute) * 60 + Time.Second) * 100
|
Time.Nanosecond,
|
||||||
+ DivU64x32(Time.Nanosecond, 10000000)
|
10000000
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sentinel value of 0 means that this is the first DHCP packet that we are
|
// Sentinel value of 0 means that this is the first DHCP packet that we are
|
||||||
|
@ -1510,14 +1510,14 @@ CalcElapsedTime (
|
|||||||
//
|
//
|
||||||
ZeroMem (&Time, sizeof (EFI_TIME));
|
ZeroMem (&Time, sizeof (EFI_TIME));
|
||||||
gRT->GetTime (&Time, NULL);
|
gRT->GetTime (&Time, NULL);
|
||||||
CurrentStamp = (UINT64)
|
CurrentStamp = MultU64x32 (
|
||||||
(
|
((((UINT32)(Time.Year - 1900) * 360 + (Time.Month - 1) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * 60 + Time.Second,
|
||||||
((((((Time.Year - 1900) * 360 +
|
100
|
||||||
(Time.Month - 1)) * 30 +
|
) +
|
||||||
(Time.Day - 1)) * 24 + Time.Hour) * 60 +
|
DivU64x32 (
|
||||||
Time.Minute) * 60 + Time.Second) * 100
|
Time.Nanosecond,
|
||||||
+ DivU64x32(Time.Nanosecond, 10000000)
|
10000000
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sentinel value of 0 means that this is the first DHCP packet that we are
|
// Sentinel value of 0 means that this is the first DHCP packet that we are
|
||||||
|
Reference in New Issue
Block a user