]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Correct the time stamp and fix the integer overflow issue.
authorJiaxin Wu <Jiaxin.wu@intel.com>
Tue, 16 Oct 2018 05:34:00 +0000 (13:34 +0800)
committerJiaxin Wu <Jiaxin.wu@intel.com>
Mon, 22 Oct 2018 01:04:56 +0000 (09:04 +0800)
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>
NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c

index 10a99a00d4b5595c93547501d7f8a2dcbe457400..9c7459c3321be0c0ab116503ee29c54290132066 100644 (file)
@@ -123,7 +123,7 @@ Dhcp6GenerateClientId (
     gRT->GetTime (&Time, NULL);\r
     Stamp = (UINT32)\r
       (\r
-        (((((Time.Year - 2000) * 360 + (Time.Month - 1)) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) *\r
+        ((((UINT32)(Time.Year - 2000) * 360 + (Time.Month - 1) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) *\r
         60 +\r
         Time.Second\r
       );\r
@@ -881,14 +881,14 @@ SetElapsedTime (
   // Generate a time stamp of the centiseconds from 2000/1/1, assume 30day/month.\r
   //\r
   gRT->GetTime (&Time, NULL);\r
-  CurrentStamp = (UINT64)\r
-    (\r
-      ((((((Time.Year - 2000) * 360 +\r
-       (Time.Month - 1)) * 30 +\r
-       (Time.Day - 1)) * 24 + Time.Hour) * 60 +\r
-       Time.Minute) * 60 + Time.Second) * 100\r
-       + DivU64x32(Time.Nanosecond, 10000000)\r
-    );\r
+  CurrentStamp = MultU64x32 (\r
+                   ((((UINT32)(Time.Year - 2000) * 360 + (Time.Month - 1) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * 60 + Time.Second,\r
+                   100\r
+                   ) +\r
+                 DivU64x32(\r
+                   Time.Nanosecond,\r
+                   10000000\r
+                   );\r
 \r
   //\r
   // Sentinel value of 0 means that this is the first DHCP packet that we are\r
index 60509fc9e61288097257cb19addf4fb2c2787e22..7ab09e0367058e163e37385cbc6b48401da81e25 100644 (file)
@@ -1510,14 +1510,14 @@ CalcElapsedTime (
   //\r
   ZeroMem (&Time, sizeof (EFI_TIME));\r
   gRT->GetTime (&Time, NULL);\r
-  CurrentStamp = (UINT64)\r
-    (\r
-      ((((((Time.Year - 1900) * 360 +\r
-       (Time.Month - 1)) * 30 +\r
-       (Time.Day - 1)) * 24 + Time.Hour) * 60 +\r
-       Time.Minute) * 60 + Time.Second) * 100\r
-       + DivU64x32(Time.Nanosecond, 10000000)\r
-    );\r
+  CurrentStamp = MultU64x32 (\r
+                   ((((UINT32)(Time.Year - 1900) * 360 + (Time.Month - 1) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * 60 + Time.Second,\r
+                   100\r
+                   ) +\r
+                 DivU64x32 (\r
+                   Time.Nanosecond,\r
+                   10000000\r
+                   );\r
 \r
   //\r
   // Sentinel value of 0 means that this is the first DHCP packet that we are\r