From nobody Sun Apr 28 18:55:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1531472931864168.10227616508712; Fri, 13 Jul 2018 02:08:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 34D0220985988; Fri, 13 Jul 2018 02:08:50 -0700 (PDT) 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) 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 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 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,347,1526367600"; d="scan'208";a="57367731" From: Star Zeng To: edk2-devel@lists.01.org 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: [edk2] [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: , Cc: Michael D Kinney , Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Jiewen.yao@intel.com Reviewed-by: jiewen.yao@intel.com --- MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c b/MdeModulePk= g/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 >=3D 3) { - if (StrCmp(Argv[2], L"GET") =3D=3D 0) { + if (StrCmp(Argv[2], L"GET") !=3D 0) { + Print(L"CapsuleApp: Unrecognized option(%s).\n", Argv[2]); + return EFI_UNSUPPORTED; + } else { + if (Argc !=3D 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 =3D StrDecimalToUintn(Argv[4]); - if (StrCmp(Argv[5], L"-O") =3D=3D 0) { - DumpFmpImage(&ImageTypeId, ImageIndex, Argv[6]); + if (StrCmp(Argv[5], L"-O") !=3D 0) { + Print(L"CapsuleApp: NO output file name.\n"); + return EFI_UNSUPPORTED; } + DumpFmpImage(&ImageTypeId, ImageIndex, Argv[6]); } } return EFI_SUCCESS; --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 18:55:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1531472934347990.6358599535747; Fri, 13 Jul 2018 02:08:54 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5C36320986AB6; Fri, 13 Jul 2018 02:08:51 -0700 (PDT) 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 DF9F3209831ED for ; Fri, 13 Jul 2018 02:08:50 -0700 (PDT) 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:50 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by orsmga006.jf.intel.com with ESMTP; 13 Jul 2018 02:08:49 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,347,1526367600"; d="scan'208";a="57367739" From: Star Zeng To: edk2-devel@lists.01.org Date: Fri, 13 Jul 2018 17:08:39 +0800 Message-Id: <1531472923-253528-3-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: [edk2] [PATCH 2/6] MdeModulePkg CapsuleApp: Fix memory leak in DumpFmpImage() 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: , Cc: Michael D Kinney , Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Image buffer should be freed after using. Cc: Michael D Kinney Cc: Jiewen Yao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Jiewen.yao@intel.com Reviewed-by: jiewen.yao@intel.com --- MdeModulePkg/Application/CapsuleApp/CapsuleDump.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c b/MdeModuleP= kg/Application/CapsuleApp/CapsuleDump.c index 6c1320942bf4..c0197dd640e4 100644 --- a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c @@ -953,5 +953,7 @@ DumpFmpImage ( Status =3D WriteFileFromBuffer(ImageName, ImageSize, Image); Print(L"CapsuleApp: Dump %g ImageIndex (0x%x) to %s %r\n", ImageTypeId, = ImageIndex, ImageName, Status); =20 + FreePool (Image); + return ; } --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 18:55:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1531472937722814.5408528195469; Fri, 13 Jul 2018 02:08:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 83F2620986AC7; Fri, 13 Jul 2018 02:08:53 -0700 (PDT) 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 5321320986AC6 for ; Fri, 13 Jul 2018 02:08:52 -0700 (PDT) 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:52 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by orsmga006.jf.intel.com with ESMTP; 13 Jul 2018 02:08:51 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,347,1526367600"; d="scan'208";a="57367743" From: Star Zeng To: edk2-devel@lists.01.org Date: Fri, 13 Jul 2018 17:08:40 +0800 Message-Id: <1531472923-253528-4-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: [edk2] [PATCH 3/6] MdeModulePkg CapsuleApp: Do not parse bits in CapsuleFlags of ESRT 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: , Cc: Michael D Kinney , Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" According to UEFI spec, only bits 0-15 of CapsuleFlags are meaningful and CapsuleGuid specific, CAPSULE_FLAGS_PERSIST_ACROSS_RESET CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE/CAPSULE_FLAGS_INITIATE_RESET defined in UEFI spec are in bits 16-31, they should not be parsed in CapsuleFlags of ESRT. CapsuleFlags The capsule flags field contains the CapsuleGuid flags (bits 0-15) as defined in the EFI_CAPSULE_HEADER that will be set in the capsule header. Cc: Michael D Kinney Cc: Jiewen Yao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Jiewen.yao@intel.com Reviewed-by: jiewen.yao@intel.com --- MdeModulePkg/Application/CapsuleApp/CapsuleDump.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c b/MdeModuleP= kg/Application/CapsuleApp/CapsuleDump.c index c0197dd640e4..97f1893ef433 100644 --- a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c @@ -454,9 +454,6 @@ DumpEsrtEntry ( Print(L" FwVersion - 0x%x\n", EsrtEntry->FwVersion); Print(L" LowestSupportedFwVersion - 0x%x\n", EsrtEntry->LowestSupported= FwVersion); Print(L" CapsuleFlags - 0x%x\n", EsrtEntry->CapsuleFlags); - Print(L" PERSIST_ACROSS_RESET - 0x%x\n", EsrtEntry->CapsuleFlags & = CAPSULE_FLAGS_PERSIST_ACROSS_RESET); - Print(L" POPULATE_SYSTEM_TABLE - 0x%x\n", EsrtEntry->CapsuleFlags & = CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE); - Print(L" INITIATE_RESET - 0x%x\n", EsrtEntry->CapsuleFlags & = CAPSULE_FLAGS_INITIATE_RESET); Print(L" LastAttemptVersion - 0x%x\n", EsrtEntry->LastAttemptVers= ion); Print(L" LastAttemptStatus - 0x%x (%a)\n", EsrtEntry->LastAttemp= tStatus, LastAttemptStatusToString(EsrtEntry->LastAttemptStatus)); } --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 18:55:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1531472950108436.9938493106923; Fri, 13 Jul 2018 02:09:10 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1D3D120986ADD; Fri, 13 Jul 2018 02:09:04 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 2DD4F209831DA for ; Fri, 13 Jul 2018 02:09:02 -0700 (PDT) Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 02:09:02 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by orsmga006.jf.intel.com with ESMTP; 13 Jul 2018 02:08:52 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,347,1526367600"; d="scan'208";a="57367750" From: Star Zeng To: edk2-devel@lists.01.org Date: Fri, 13 Jul 2018 17:08:41 +0800 Message-Id: <1531472923-253528-5-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: [edk2] [PATCH 4/6] MdeModulePkg CapsuleApp: Show clear message when option is unrecognized 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: , Cc: Michael D Kinney , Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Michael D Kinney Cc: Jiewen Yao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Jiewen.yao@intel.com Reviewed-by: jiewen.yao@intel.com --- MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c b/MdeModulePk= g/Application/CapsuleApp/CapsuleApp.c index 80b66bc6f371..a83ebf3d101b 100644 --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c @@ -850,10 +850,17 @@ UefiMain ( } return EFI_SUCCESS; } + if (StrCmp(Argv[1], L"-E") =3D=3D 0) { DumpEsrtData(); return EFI_SUCCESS; } + + if (Argv[1][0] =3D=3D L'-') { + Print(L"CapsuleApp: Unrecognized option(%s).\n", Argv[1]); + return EFI_UNSUPPORTED; + } + CapsuleFirstIndex =3D 1; NoReset =3D FALSE; if ((Argc > 1) && (StrCmp(Argv[Argc - 1], L"-NR") =3D=3D 0)) { --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 18:55:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1531472942988413.7506656947986; Fri, 13 Jul 2018 02:09:02 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B585820986ACF; Fri, 13 Jul 2018 02:09:02 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 DBA25209831DA for ; Fri, 13 Jul 2018 02:09:01 -0700 (PDT) Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 02:09:02 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by orsmga006.jf.intel.com with ESMTP; 13 Jul 2018 02:08:54 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,347,1526367600"; d="scan'208";a="57367754" From: Star Zeng To: edk2-devel@lists.01.org Date: Fri, 13 Jul 2018 17:08:42 +0800 Message-Id: <1531472923-253528-6-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: [edk2] [PATCH 5/6] MdeModulePkg CapsuleApp: Check capsule header before using its Flags 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: , Cc: Michael D Kinney , Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Michael D Kinney Cc: Jiewen Yao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Jiewen.yao@intel.com Reviewed-by: jiewen.yao@intel.com --- MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 38 ++++++++++++++++++++= ++++ 1 file changed, 38 insertions(+) diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c b/MdeModulePk= g/Application/CapsuleApp/CapsuleApp.c index a83ebf3d101b..dbcffddea9ce 100644 --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c @@ -716,6 +716,40 @@ CleanGatherList ( } =20 /** + Validate if it is valid capsule header + + This function assumes the caller provided correct CapsuleHeader pointer + and CapsuleSize. + + This function validates the fields in EFI_CAPSULE_HEADER. + + @param[in] CapsuleHeader Points to a capsule header. + @param[in] CapsuleSize Size of the whole capsule image. + +**/ +BOOLEAN +IsValidCapsuleHeader ( + IN EFI_CAPSULE_HEADER *CapsuleHeader, + IN UINT64 CapsuleSize + ) +{ + if (CapsuleSize < sizeof (EFI_CAPSULE_HEADER)) { + return FALSE; + } + if (CapsuleHeader->CapsuleImageSize !=3D CapsuleSize) { + return FALSE; + } + if (CapsuleHeader->HeaderSize > CapsuleHeader->CapsuleImageSize) { + return FALSE; + } + if (CapsuleHeader->HeaderSize < sizeof (EFI_CAPSULE_HEADER)) { + return FALSE; + } + + return TRUE; +} + +/** Print APP usage. **/ VOID @@ -891,6 +925,10 @@ UefiMain ( Print(L"CapsuleApp: capsule image (%s) is not found.\n", CapsuleName= ); goto Done; } + if (!IsValidCapsuleHeader (CapsuleBuffer[Index], FileSize[Index])) { + Print(L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", C= apsuleName); + return EFI_INVALID_PARAMETER; + } } =20 // --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 18:55:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1531472946419604.9062217921165; Fri, 13 Jul 2018 02:09:06 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E3F4520986ADA; Fri, 13 Jul 2018 02:09:03 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 0AA1B20986ACF for ; Fri, 13 Jul 2018 02:09:02 -0700 (PDT) Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 02:09:02 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by orsmga006.jf.intel.com with ESMTP; 13 Jul 2018 02:08:55 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,347,1526367600"; d="scan'208";a="57367758" From: Star Zeng To: edk2-devel@lists.01.org Date: Fri, 13 Jul 2018 17:08:43 +0800 Message-Id: <1531472923-253528-7-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: [edk2] [PATCH 6/6] MdeModulePkg CapsuleApp: Use EFI_UNSUPPORTED for incorrect Argc case 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: , Cc: Michael D Kinney , Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Align code to use EFI_UNSUPPORTED for all incorrect Argc cases. Cc: Michael D Kinney Cc: Jiewen Yao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Jiewen.yao@intel.com Reviewed-by: jiewen.yao@intel.com --- MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c b/MdeModulePk= g/Application/CapsuleApp/CapsuleApp.c index dbcffddea9ce..df5de91ef524 100644 --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c @@ -193,7 +193,7 @@ CreateBmpFmp ( // VerticalResolution >=3D BMP_IMAGE_HEADER.PixelHeight =20 if (Argc !=3D 5) { - Print(L"CapsuleApp: Invalid Parameter.\n"); + Print(L"CapsuleApp: Incorrect parameter count.\n"); return EFI_UNSUPPORTED; } =20 @@ -387,7 +387,7 @@ CreateNestedFmp ( EFI_STATUS Status; =20 if (Argc !=3D 5) { - Print(L"CapsuleApp: Invalid Parameter.\n"); + Print(L"CapsuleApp: Incorrect parameter count.\n"); return EFI_UNSUPPORTED; } =20 @@ -793,7 +793,8 @@ PrintUsage ( @param[in] SystemTable The system table. =20 @retval EFI_SUCCESS Command completed successfully. - @retval EFI_INVALID_PARAMETER Command usage error. + @retval EFI_UNSUPPORTED Command usage unsupported. + @retval EFI_INVALID_PARAMETER Command usage invalid. @retval EFI_NOT_FOUND The input file can't be found. **/ EFI_STATUS @@ -824,12 +825,12 @@ UefiMain ( } if (Argc < 2) { PrintUsage(); - return EFI_INVALID_PARAMETER; + return EFI_UNSUPPORTED; } if (StrCmp(Argv[1], L"-D") =3D=3D 0) { - if (Argc < 3) { - Print(L"CapsuleApp: NO input capsule name.\n"); - return EFI_INVALID_PARAMETER; + if (Argc !=3D 3) { + Print(L"CapsuleApp: Incorrect parameter count.\n"); + return EFI_UNSUPPORTED; } Status =3D DumpCapsule(Argv[2]); return Status; --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel