From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 E192F21C8F634 for ; Thu, 22 Jun 2017 00:23:04 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2017 00:24:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,372,1493708400"; d="scan'208";a="870559871" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.9.2]) by FMSMGA003.fm.intel.com with ESMTP; 22 Jun 2017 00:24:28 -0700 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Ruiyu Ni , Jaben Carsey Date: Thu, 22 Jun 2017 15:24:25 +0800 Message-Id: <1498116265-150004-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [PATCH] ShellPkg DmpStore: Make NameSize to be consistent with name buffer X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jun 2017 07:23:05 -0000 Current code will allocate pool to hold the null char for name buffer when PrevName==NULL, but the NameSize is still 0. For this case, GetNextVariableName will return EFI_INVALID_PARAMETER to follow UEFI 2.7 spec. UEFI 2.7 spec: The VariableNameSize must not be smaller the size of the variable name string passed to GetNextVariableName() on input in the VariableName buffer. EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of the input VariableName buffer. This patch is to make NameSize to be consistent with name buffer. Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng --- ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c index 23db54553f11..aeffc89b1991 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c @@ -436,6 +436,7 @@ CascadeProcessVariables ( StrnCatGrow(&FoundVarName, &NameSize, PrevName, 0); } else { FoundVarName = AllocateZeroPool(sizeof(CHAR16)); + NameSize = sizeof(CHAR16); } Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid); -- 2.7.0.windows.1