public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ShellPkg DmpStore: Make NameSize to be consistent with name buffer
@ 2017-06-22  7:24 Star Zeng
  2017-06-22  8:11 ` Ni, Ruiyu
  0 siblings, 1 reply; 2+ messages in thread
From: Star Zeng @ 2017-06-22  7:24 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Ruiyu Ni, Jaben Carsey

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>
---
 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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ShellPkg DmpStore: Make NameSize to be consistent with name buffer
  2017-06-22  7:24 [PATCH] ShellPkg DmpStore: Make NameSize to be consistent with name buffer Star Zeng
@ 2017-06-22  8:11 ` Ni, Ruiyu
  0 siblings, 0 replies; 2+ messages in thread
From: Ni, Ruiyu @ 2017-06-22  8:11 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Carsey, Jaben

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Thanks/Ray

> -----Original Message-----
> From: Zeng, Star
> Sent: Thursday, June 22, 2017 3:24 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>;
> Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [PATCH] ShellPkg DmpStore: Make NameSize to be consistent with
> name buffer
> 
> 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>
> ---
>  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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-22  8:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-22  7:24 [PATCH] ShellPkg DmpStore: Make NameSize to be consistent with name buffer Star Zeng
2017-06-22  8:11 ` Ni, Ruiyu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox