]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
MdeModulePkg: Replace unsafe string functions.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiConfig.c
index 702f4f43cf61d4103325e963fc026d6f12c64b24..7b77fd386bde53bb241711d3b807b129d86c2f60 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Helper functions for configuring or getting the parameters relating to iSCSI.\r
 \r
-Copyright (c) 2004 - 2012, 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
@@ -227,6 +227,7 @@ IScsiUpdateDeviceList (
                   );\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     DeviceList = (ISCSI_DEVICE_LIST *) AllocatePool (DataSize);\r
+    ASSERT (DeviceList != NULL);\r
 \r
     gRT->GetVariable (\r
           L"iSCSIDeviceList",\r
@@ -291,6 +292,7 @@ IScsiUpdateDeviceList (
   //\r
   DeviceListSize        = sizeof (ISCSI_DEVICE_LIST) + (NumHandles - 1) * sizeof (ISCSI_MAC_INFO);\r
   DeviceList            = (ISCSI_DEVICE_LIST *) AllocatePool (DeviceListSize);\r
+  ASSERT (DeviceList != NULL);\r
   DeviceList->NumDevice = (UINT8) NumHandles;\r
 \r
   for (Index = 0; Index < NumHandles; Index++) {\r
@@ -776,7 +778,7 @@ IScsiFormCallback (
       if (EFI_ERROR (Status)) {\r
         CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid iSCSI Name!", NULL);\r
       } else {\r
-        AsciiStrCpy (Private->Current->SessionConfigData.TargetName, IScsiName);\r
+        AsciiStrCpyS (Private->Current->SessionConfigData.TargetName, ISCSI_NAME_MAX_SIZE, IScsiName);\r
       }\r
 \r
       break;\r
@@ -870,6 +872,23 @@ IScsiFormCallback (
             Status = EFI_INVALID_PARAMETER;\r
             break;\r
           }\r
+\r
+          //\r
+          // Validate iSCSI target name configuration again:\r
+          // The format of iSCSI target name is already verified when user input the name;\r
+          // here we only check the case user does not input the name.\r
+          //\r
+          if (Private->Current->SessionConfigData.TargetName[0] == '\0') {\r
+            CreatePopUp (\r
+              EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+              &Key,\r
+              L"iSCSI target name is NULL!",\r
+              NULL\r
+              );\r
+            Status = EFI_INVALID_PARAMETER;\r
+            break;\r
+          }\r
+\r
         }\r
 \r
         if (IfrNvData->CHAPType != ISCSI_CHAP_NONE) {\r
@@ -1171,7 +1190,7 @@ IScsiConfigFormInit (
   CallbackInfo->RegisteredHandle = HiiAddPackages (\r
                                      &gIp4IScsiConfigGuid,\r
                                      CallbackInfo->DriverHandle,\r
-                                     IScsiDxeStrings,\r
+                                     IScsi4DxeStrings,\r
                                      IScsiConfigDxeBin,\r
                                      NULL\r
                                      );\r