From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 AAC7D203BBB8E for ; Fri, 11 May 2018 01:26:06 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 May 2018 01:26:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,387,1520924400"; d="scan'208";a="55003716" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga001.jf.intel.com with ESMTP; 11 May 2018 01:26:05 -0700 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 11 May 2018 01:26:05 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 11 May 2018 01:26:05 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.79]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.40]) with mapi id 14.03.0319.002; Fri, 11 May 2018 16:26:03 +0800 From: "Zeng, Star" To: cinnamon shia , "edk2-devel@lists.01.org" CC: "lersek@redhat.com" , Ansen Huang , "Zeng, Star" Thread-Topic: [PATCH 1/2] MdeModulePkg Variable: Failed to set a variable if the remaining size is equal to the variable data size. Thread-Index: AQHT6N8dfyxLsM4k60yof2L7op/F1aQqMOsA Date: Fri, 11 May 2018 08:26:02 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BAEB80F@shsmsx102.ccr.corp.intel.com> References: <20180511041753.32040-1-cinnamon.shia@hpe.com> In-Reply-To: <20180511041753.32040-1-cinnamon.shia@hpe.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 1/2] MdeModulePkg Variable: Failed to set a variable if the remaining size is equal to the variable data size. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 May 2018 08:26:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Good catch and I agree the code change. Only one minor comment. Please reduce the title length to <=3D 72 chars as I know it is requirement= for patch check (PatchCheck.py in BaseTools) and push to server. Thanks, Star -----Original Message----- From: cinnamon shia [mailto:cinnamon.shia@hpe.com]=20 Sent: Friday, May 11, 2018 12:18 PM To: edk2-devel@lists.01.org Cc: lersek@redhat.com; Zeng, Star ; cinnamon shia ; Ansen Huang Subject: [PATCH 1/2] MdeModulePkg Variable: Failed to set a variable if the= remaining size is equal to the variable data size. Fix the issue that failed to update or add a UEFI variable if the remaining= size is equal to the data size of the variable. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: cinnamon shia Signed-off-by: Ansen Huang --- MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeMod= ulePkg/Universal/Variable/RuntimeDxe/Variable.c index 6caf603b3d..7303681aaa 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -17,7 +17,7 @@ integer overflow. It should also check attribute to avoid authentication= bypass. =20 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-(C) Copyright 2015 Hewlett Packard Enterprise Development LP
+(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -288,7 +288,7 @@ UpdateVariableStore ( DataPtr +=3D mVariableModuleGlobal->VariableGlobal.NonVolatileVariab= leBase; } =20 - if ((DataPtr + DataSize) >=3D ((EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 = *) FwVolHeader + FwVolHeader->FvLength))) { + if ((DataPtr + DataSize) > ((EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) = FwVolHeader + FwVolHeader->FvLength))) { return EFI_INVALID_PARAMETER; } } else { @@ -301,7 +301,7 @@ UpdateVariableStore ( DataPtr +=3D mVariableModuleGlobal->VariableGlobal.VolatileVariableB= ase; } =20 - if ((DataPtr + DataSize) >=3D ((UINTN) ((UINT8 *) VolatileBase + Volat= ileBase->Size))) { + if ((DataPtr + DataSize) > ((UINTN) ((UINT8 *) VolatileBase + Volatile= Base->Size))) { return EFI_INVALID_PARAMETER; } =20 --=20 2.16.1.windows.4