]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg DmpStore: Make NameSize to be consistent with name buffer
authorStar Zeng <star.zeng@intel.com>
Thu, 22 Jun 2017 07:22:33 +0000 (15:22 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 27 Jun 2017 05:35:28 +0000 (13:35 +0800)
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 <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c

index 23db54553f11ece5e1d629d7e9998360a7144016..aeffc89b1991f5d7e96f60c6aa9a0820584d75dd 100644 (file)
@@ -436,6 +436,7 @@ CascadeProcessVariables (
     StrnCatGrow(&FoundVarName, &NameSize, PrevName, 0);\r
   } else {\r
     FoundVarName = AllocateZeroPool(sizeof(CHAR16));\r
+    NameSize = sizeof(CHAR16);\r
   }\r
 \r
   Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);\r