]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
Refine soma code to make code run safely.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / UefiPxeBcDxe / PxeBcDhcp.c
index ce58321eb06ec2e423924657a20b694db9247244..6b25cab33d58cd41223cfb5a7ec78418010e7bba 100644 (file)
@@ -852,7 +852,7 @@ PxeBcDhcpCallBack (
         ZeroMem (DhcpHeader->ClientHwAddr, sizeof (EFI_GUID));\r
       }\r
 \r
-      DhcpHeader->HwAddrLen = sizeof (EFI_GUID);\r
+      DhcpHeader->HwAddrLen = (UINT8) sizeof (EFI_GUID);\r
     }\r
 \r
     if (Dhcp4Event == Dhcp4SendDiscover) {\r
@@ -948,7 +948,7 @@ PxeBcBuildDhcpOptions (
     // Append max message size.\r
     //\r
     OptList[Index]->OpCode  = PXEBC_DHCP4_TAG_MAXMSG;\r
-    OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE);\r
+    OptList[Index]->Length  = (UINT8) sizeof (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE);\r
     OptEnt.MaxMesgSize      = (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *) OptList[Index]->Data;\r
     Value                   = NTOHS (PXEBC_DHCP4_MAX_PACKET_SIZE);\r
     CopyMem (&OptEnt.MaxMesgSize->Size, &Value, sizeof (UINT16));\r
@@ -1003,7 +1003,7 @@ PxeBcBuildDhcpOptions (
   // Append UUID/Guid-based client identifier option\r
   //\r
   OptList[Index]->OpCode  = PXEBC_PXE_DHCP4_TAG_UUID;\r
-  OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_UUID);\r
+  OptList[Index]->Length  = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UUID);\r
   OptEnt.Uuid             = (PXEBC_DHCP4_OPTION_UUID *) OptList[Index]->Data;\r
   OptEnt.Uuid->Type       = 0;\r
   Index++;\r
@@ -1022,7 +1022,7 @@ PxeBcBuildDhcpOptions (
   // Append client network device interface option\r
   //\r
   OptList[Index]->OpCode  = PXEBC_PXE_DHCP4_TAG_UNDI;\r
-  OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_UNDI);\r
+  OptList[Index]->Length  = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UNDI);\r
   OptEnt.Undi             = (PXEBC_DHCP4_OPTION_UNDI *) OptList[Index]->Data;\r
   if (Private->Nii != NULL) {\r
     OptEnt.Undi->Type       = Private->Nii->Type;\r
@@ -1041,7 +1041,7 @@ PxeBcBuildDhcpOptions (
   // Append client system architecture option\r
   //\r
   OptList[Index]->OpCode  = PXEBC_PXE_DHCP4_TAG_ARCH;\r
-  OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_ARCH);\r
+  OptList[Index]->Length  = (UINT8) sizeof (PXEBC_DHCP4_OPTION_ARCH);\r
   OptEnt.Arch             = (PXEBC_DHCP4_OPTION_ARCH *) OptList[Index]->Data;\r
   Value                   = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);\r
   CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));\r
@@ -1052,7 +1052,7 @@ PxeBcBuildDhcpOptions (
   // Append client system architecture option\r
   //\r
   OptList[Index]->OpCode  = PXEBC_DHCP4_TAG_CLASS_ID;\r
-  OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_CLID);\r
+  OptList[Index]->Length  = (UINT8) sizeof (PXEBC_DHCP4_OPTION_CLID);\r
   OptEnt.Clid             = (PXEBC_DHCP4_OPTION_CLID *) OptList[Index]->Data;\r
   CopyMem (OptEnt.Clid, DEFAULT_CLASS_ID_DATA, sizeof (PXEBC_DHCP4_OPTION_CLID));\r
   CvtNum (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE, OptEnt.Clid->ArchitectureType, sizeof (OptEnt.Clid->ArchitectureType));\r
@@ -1149,7 +1149,7 @@ PxeBcDiscvBootService (
     //\r
     // Add vendor option of PXE_BOOT_ITEM\r
     //\r
-    VendorOptLen      = (sizeof (EFI_DHCP4_PACKET_OPTION) - 1) * 2 + sizeof (PXEBC_OPTION_BOOT_ITEM) + 1;\r
+    VendorOptLen = (UINT8) ((sizeof (EFI_DHCP4_PACKET_OPTION) - 1) * 2 + sizeof (PXEBC_OPTION_BOOT_ITEM) + 1);\r
     OptList[OptCount] = AllocatePool (VendorOptLen);\r
     if (OptList[OptCount] == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
@@ -1159,7 +1159,7 @@ PxeBcDiscvBootService (
     OptList[OptCount]->Length     = (UINT8) (VendorOptLen - 2);\r
     PxeOpt                        = (EFI_DHCP4_PACKET_OPTION *) OptList[OptCount]->Data;\r
     PxeOpt->OpCode                = PXEBC_VENDOR_TAG_BOOT_ITEM;\r
-    PxeOpt->Length                = sizeof (PXEBC_OPTION_BOOT_ITEM);\r
+    PxeOpt->Length                = (UINT8) sizeof (PXEBC_OPTION_BOOT_ITEM);\r
     PxeBootItem                   = (PXEBC_OPTION_BOOT_ITEM *) PxeOpt->Data;\r
     PxeBootItem->Type             = HTONS (Type);\r
     PxeBootItem->Layer            = HTONS (*Layer);\r
@@ -1187,7 +1187,7 @@ PxeBcDiscvBootService (
       ZeroMem (DhcpHeader->ClientHwAddr, sizeof (EFI_GUID));\r
     }\r
 \r
-    DhcpHeader->HwAddrLen = sizeof (EFI_GUID);\r
+    DhcpHeader->HwAddrLen = (UINT8) sizeof (EFI_GUID);\r
   }\r
 \r
   Xid                                 = NET_RANDOM (NetRandomInitSeed ());\r