From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5D7F1209831E1 for ; Fri, 13 Jul 2018 02:08:49 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 02:08:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,347,1526367600"; d="scan'208";a="57367731" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by orsmga006.jf.intel.com with ESMTP; 13 Jul 2018 02:08:48 -0700 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Michael D Kinney , Jiewen Yao , Yonghong Zhu Date: Fri, 13 Jul 2018 17:08:38 +0800 Message-Id: <1531472923-253528-2-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1531472923-253528-1-git-send-email-star.zeng@intel.com> References: <1531472923-253528-1-git-send-email-star.zeng@intel.com> Subject: [PATCH 1/6] MdeModulePkg CapsuleApp: Check Arg count for -P GET option X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2018 09:08:49 -0000 Also add help info for CapsuleApp -P GET option. Cc: Michael D Kinney Cc: Jiewen Yao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng --- MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c index e9be39fd71be..80b66bc6f371 100644 --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c @@ -740,7 +740,8 @@ PrintUsage ( Print(L" which is defined in UEFI specification.\n"); Print(L" -C: Clear capsule report variable (EFI_CAPSULE_REPORT_GUID),\n"); Print(L" which is defined in UEFI specification.\n"); - Print(L" -P: Dump UEFI FMP protocol info.\n"); + Print(L" -P: Dump UEFI FMP protocol info, or get image with specified\n"); + Print(L" ImageTypeId and index to a file if 'GET' option is used.\n"); Print(L" -E: Dump UEFI ESRT table info.\n"); Print(L" -G: Convert a BMP file to be an UX capsule,\n"); Print(L" according to Windows Firmware Update document\n"); @@ -820,7 +821,15 @@ UefiMain ( DumpFmpData(); } if (Argc >= 3) { - if (StrCmp(Argv[2], L"GET") == 0) { + if (StrCmp(Argv[2], L"GET") != 0) { + Print(L"CapsuleApp: Unrecognized option(%s).\n", Argv[2]); + return EFI_UNSUPPORTED; + } else { + if (Argc != 7) { + Print(L"CapsuleApp: Incorrect parameter count.\n"); + return EFI_UNSUPPORTED; + } + EFI_GUID ImageTypeId; UINTN ImageIndex; // @@ -832,9 +841,11 @@ UefiMain ( return EFI_INVALID_PARAMETER; } ImageIndex = StrDecimalToUintn(Argv[4]); - if (StrCmp(Argv[5], L"-O") == 0) { - DumpFmpImage(&ImageTypeId, ImageIndex, Argv[6]); + if (StrCmp(Argv[5], L"-O") != 0) { + Print(L"CapsuleApp: NO output file name.\n"); + return EFI_UNSUPPORTED; } + DumpFmpImage(&ImageTypeId, ImageIndex, Argv[6]); } } return EFI_SUCCESS; -- 2.7.0.windows.1