]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
MdeModulePkg: Fix issue about current Ip4Dxe implementation for DHCP DORA process
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiMisc.c
index 1cb1fb89d9ec97c44160a8f6f28ddb3f189537be..ebd9f5b40dd62c51666423ca7ca8f0368495e105 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Miscellaneous routines for iSCSI driver.\r
 \r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -204,7 +204,7 @@ IScsiLunToUnicodeStr (
   for (Index = 0; Index < 4; Index++) {\r
 \r
     if ((Lun[2 * Index] | Lun[2 * Index + 1]) == 0) {\r
-      StrCpy (TempStr, L"0-");\r
+      CopyMem(TempStr, L"0-", sizeof (L"0-"));\r
     } else {\r
       TempStr[0]  = (CHAR16) IScsiHexString[Lun[2 * Index] >> 4];\r
       TempStr[1]  = (CHAR16) IScsiHexString[Lun[2 * Index] & 0x0F];\r
@@ -814,15 +814,24 @@ IScsiGetTcpConnDevicePath (
       DPathNode->Ipv4.StaticIpAddress = \r
         (BOOLEAN) (!Session->ConfigData.NvData.InitiatorInfoFromDhcp);\r
 \r
-      IP4_COPY_ADDRESS (\r
-        &DPathNode->Ipv4.GatewayIpAddress,\r
-        &Session->ConfigData.NvData.Gateway\r
-        );\r
+      //\r
+      //  Add a judgement here to support previous versions of IPv4_DEVICE_PATH.\r
+      //  In previous versions of IPv4_DEVICE_PATH, GatewayIpAddress and SubnetMask\r
+      //  do not exist.\r
+      //  In new version of IPv4_DEVICE_PATH, structcure length is 27.\r
+      //\r
+      if (DevicePathNodeLength (&DPathNode->Ipv4) == IP4_NODE_LEN_NEW_VERSIONS) {  \r
+\r
+        IP4_COPY_ADDRESS (\r
+          &DPathNode->Ipv4.GatewayIpAddress,\r
+          &Session->ConfigData.NvData.Gateway\r
+          );\r
 \r
-      IP4_COPY_ADDRESS (\r
-        &DPathNode->Ipv4.SubnetMask,\r
-        &Session->ConfigData.NvData.SubnetMask\r
-        );\r
+        IP4_COPY_ADDRESS (\r
+          &DPathNode->Ipv4.SubnetMask,\r
+          &Session->ConfigData.NvData.SubnetMask\r
+          );\r
+      }\r
 \r
       break;\r
     }\r