]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
Comment's added and fixed.
[mirror_edk2.git] / ShellPkg / Library / UefiShellNetwork1CommandsLib / Ifconfig.c
index 2e8a09fc339f8cf6a3702ccc0f9082698a207a11..d4326448f63576cb2eb3f74f5d07ba1edd60b170 100644 (file)
@@ -606,13 +606,19 @@ IfconfigGetAllNicInfoByHii (
     // Construct configuration request string header\r
     //\r
     ConfigHdr = ConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, ChildHandle);\r
-    Length = StrLen (ConfigHdr);\r
+    if (ConfigHdr != NULL) {\r
+      Length = StrLen (ConfigHdr);\r
+    } else {\r
+      Length = 0;\r
+    }\r
     ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));\r
     if (ConfigResp == NULL) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto ON_ERROR;\r
     }\r
-    StrCpy (ConfigResp, ConfigHdr);\r
+    if (ConfigHdr != NULL) {\r
+      StrCpy (ConfigResp, ConfigHdr);\r
+    }\r
  \r
     //\r
     // Append OFFSET/WIDTH pair\r
@@ -772,10 +778,20 @@ IfconfigSetNicAddrByHii (
   // Construct config request string header\r
   //\r
   ConfigHdr = ConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, ChildHandle);\r
-\r
-  Length = StrLen (ConfigHdr);\r
+  if (ConfigHdr != NULL) {\r
+    Length = StrLen (ConfigHdr);\r
+  } else {\r
+    ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
+  }\r
   ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));\r
-  StrCpy (ConfigResp, ConfigHdr);\r
+  if (ConfigResp == NULL) {\r
+    ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
+  }\r
+  if (ConfigHdr != NULL) {\r
+    StrCpy (ConfigResp, ConfigHdr);\r
+  }\r
 \r
   NicConfig = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
   if (NicConfig == NULL) {\r
@@ -1657,9 +1673,9 @@ ShellCommandRunIfconfig (
   ListOperation  = ShellCommandLineGetFlag(Package, L"-l");\r
   SetOperation   = ShellCommandLineGetFlag(Package, L"-s");\r
 \r
-  if (ClearOperation && ListOperation \r
-    ||SetOperation   && ListOperation \r
-    ||ClearOperation && SetOperation \r
+  if ((ClearOperation && ListOperation)\r
+    ||(SetOperation   && ListOperation)\r
+    ||(ClearOperation && SetOperation)\r
     ) {\r
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellNetwork1HiiHandle);\r
     ShellStatus = SHELL_INVALID_PARAMETER;\r