]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg CapsuleApp: Check Arg count for -P GET option
authorStar Zeng <star.zeng@intel.com>
Wed, 11 Jul 2018 08:35:02 +0000 (16:35 +0800)
committerStar Zeng <star.zeng@intel.com>
Mon, 23 Jul 2018 01:17:19 +0000 (09:17 +0800)
Also add help info for CapsuleApp -P GET option.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Application/CapsuleApp/CapsuleApp.c

index e9be39fd71beba03b5a38dd13c7893afbbdd88ef..80b66bc6f371f4c6bef0e5f91c2fd9955aa8955d 100644 (file)
@@ -740,7 +740,8 @@ PrintUsage (
   Print(L"       which is defined in UEFI specification.\n");\r
   Print(L"  -C:  Clear capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");\r
   Print(L"       which is defined in UEFI specification.\n");\r
   Print(L"       which is defined in UEFI specification.\n");\r
   Print(L"  -C:  Clear capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");\r
   Print(L"       which is defined in UEFI specification.\n");\r
-  Print(L"  -P:  Dump UEFI FMP protocol info.\n");\r
+  Print(L"  -P:  Dump UEFI FMP protocol info, or get image with specified\n");\r
+  Print(L"       ImageTypeId and index to a file if 'GET' option is used.\n");\r
   Print(L"  -E:  Dump UEFI ESRT table info.\n");\r
   Print(L"  -G:  Convert a BMP file to be an UX capsule,\n");\r
   Print(L"       according to Windows Firmware Update document\n");\r
   Print(L"  -E:  Dump UEFI ESRT table info.\n");\r
   Print(L"  -G:  Convert a BMP file to be an UX capsule,\n");\r
   Print(L"       according to Windows Firmware Update document\n");\r
@@ -820,7 +821,15 @@ UefiMain (
       DumpFmpData();\r
     }\r
     if (Argc >= 3) {\r
       DumpFmpData();\r
     }\r
     if (Argc >= 3) {\r
-      if (StrCmp(Argv[2], L"GET") == 0) {\r
+      if (StrCmp(Argv[2], L"GET") != 0) {\r
+        Print(L"CapsuleApp: Unrecognized option(%s).\n", Argv[2]);\r
+        return EFI_UNSUPPORTED;\r
+      } else {\r
+        if (Argc != 7) {\r
+          Print(L"CapsuleApp: Incorrect parameter count.\n");\r
+          return EFI_UNSUPPORTED;\r
+        }\r
+\r
         EFI_GUID  ImageTypeId;\r
         UINTN     ImageIndex;\r
         //\r
         EFI_GUID  ImageTypeId;\r
         UINTN     ImageIndex;\r
         //\r
@@ -832,9 +841,11 @@ UefiMain (
           return EFI_INVALID_PARAMETER;\r
         }\r
         ImageIndex = StrDecimalToUintn(Argv[4]);\r
           return EFI_INVALID_PARAMETER;\r
         }\r
         ImageIndex = StrDecimalToUintn(Argv[4]);\r
-        if (StrCmp(Argv[5], L"-O") == 0) {\r
-          DumpFmpImage(&ImageTypeId, ImageIndex, Argv[6]);\r
+        if (StrCmp(Argv[5], L"-O") != 0) {\r
+          Print(L"CapsuleApp: NO output file name.\n");\r
+          return EFI_UNSUPPORTED;\r
         }\r
         }\r
+        DumpFmpImage(&ImageTypeId, ImageIndex, Argv[6]);\r
       }\r
     }\r
     return EFI_SUCCESS;\r
       }\r
     }\r
     return EFI_SUCCESS;\r