]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c
ShellPkg/for: Fix potential null pointer deference
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel3CommandsLib / Type.c
index dffefd1234d2d5e794d2538ddb7c42211c64d83b..50d18e45aacd80ac1cceb57ca468df9882bec13d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for Type shell level 3 function.\r
 \r
-  Copyright (c) 2013, Hewlett-Packard Development Company, L.P.\r
+  (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
   Copyright (c) 2009 - 2011, 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
@@ -30,7 +30,6 @@
   @retval EFI_SUCCESS           The operation was successful.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 TypeFileByHandle (\r
   IN SHELL_FILE_HANDLE Handle,\r
   IN BOOLEAN Ascii,\r
@@ -208,7 +207,7 @@ ShellCommandRunType (
   Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
   if (EFI_ERROR(Status)) {\r
     if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"type", ProblemParam);  \r
       FreePool(ProblemParam);\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
@@ -225,13 +224,13 @@ ShellCommandRunType (
     UnicodeMode = ShellCommandLineGetFlag(Package, L"-u");\r
 \r
     if (AsciiMode && UnicodeMode) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"-a & -u");\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"type", L"-a & -u");  \r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
    } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {\r
       //\r
       // we insufficient parameters\r
       //\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle, L"type");  \r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
       //\r
@@ -244,7 +243,7 @@ ShellCommandRunType (
          ){\r
         Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ, &FileList);\r
         if (EFI_ERROR(Status)) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, (CHAR16*)Param);\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"type", (CHAR16*)Param);  \r
           ShellStatus = SHELL_NOT_FOUND;\r
           break;\r
         }\r
@@ -257,7 +256,7 @@ ShellCommandRunType (
           // check that we have at least 1 file\r
           //\r
           if (FileList == NULL || IsListEmpty(&FileList->Link)) {\r
-            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, Param);\r
+            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, L"type", Param);  \r
             continue;\r
           } else {\r
             //\r
@@ -276,7 +275,7 @@ ShellCommandRunType (
               // make sure the file opened ok\r
               //\r
               if (EFI_ERROR(Node->Status)){\r
-                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Node->FileName, Node->Status);\r
+                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"type", Node->FileName);  \r
                 ShellStatus = SHELL_NOT_FOUND;\r
                 continue;\r
               }\r
@@ -285,7 +284,7 @@ ShellCommandRunType (
               // make sure its not a directory\r
               //\r
               if (FileHandleIsDirectory(Node->Handle) == EFI_SUCCESS) {\r
-                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_IS_DIR), gShellLevel3HiiHandle, Node->FileName);\r
+                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_IS_DIR), gShellLevel3HiiHandle, L"type", Node->FileName);  \r
                 ShellStatus = SHELL_NOT_FOUND;\r
                 continue;\r
               }\r
@@ -295,7 +294,7 @@ ShellCommandRunType (
               //\r
               Status = TypeFileByHandle (Node->Handle, AsciiMode, UnicodeMode);\r
               if (EFI_ERROR(Status)) {\r
-                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TYP_ERROR), gShellLevel3HiiHandle, Node->FileName, Status);\r
+                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TYP_ERROR), gShellLevel3HiiHandle, L"type", Node->FileName);\r
                 ShellStatus = SHELL_INVALID_PARAMETER;\r
               }\r
               ASSERT(ShellStatus == SHELL_SUCCESS);\r