public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/Variable/Pei: Update the condition in if statement
@ 2019-10-17  3:19 Zhang, Shenglei
  2019-10-30  6:51 ` Wu, Hao A
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang, Shenglei @ 2019-10-17  3:19 UTC (permalink / raw)
  To: devel; +Cc: Hao A Wu, Liming Gao

IndexTable->Length is used as index in array IndexTable->Index[].
So IndexTable->Length needs to be checked, which should be less than
the array size.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
 MdeModulePkg/Universal/Variable/Pei/Variable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c b/MdeModulePkg/Universal/Variable/Pei/Variable.c
index 715802f33c29..f61465fc3045 100644
--- a/MdeModulePkg/Universal/Variable/Pei/Variable.c
+++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c
@@ -896,7 +896,7 @@ FindVariableEx (
       //
       if ((IndexTable != NULL) && !StopRecord) {
         Offset = (UINTN) Variable - (UINTN) LastVariable;
-        if ((Offset > 0x0FFFF) || (IndexTable->Length == sizeof (IndexTable->Index) / sizeof (IndexTable->Index[0]))) {
+        if ((Offset > 0x0FFFF) || (IndexTable->Length >= sizeof (IndexTable->Index) / sizeof (IndexTable->Index[0]))) {
           //
           // Stop to record if the distance of two neighbouring VAR_ADDED variable is larger than the allowable scope(UINT16),
           // or the record buffer is full.
-- 
2.18.0.windows.1


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

* Re: [PATCH] MdeModulePkg/Variable/Pei: Update the condition in if statement
  2019-10-17  3:19 [PATCH] MdeModulePkg/Variable/Pei: Update the condition in if statement Zhang, Shenglei
@ 2019-10-30  6:51 ` Wu, Hao A
  0 siblings, 0 replies; 2+ messages in thread
From: Wu, Hao A @ 2019-10-30  6:51 UTC (permalink / raw)
  To: Zhang, Shenglei, devel@edk2.groups.io; +Cc: Gao, Liming

> -----Original Message-----
> From: Zhang, Shenglei
> Sent: Thursday, October 17, 2019 11:20 AM
> To: devel@edk2.groups.io
> Cc: Wu, Hao A; Gao, Liming
> Subject: [PATCH] MdeModulePkg/Variable/Pei: Update the condition in if
> statement
> 
> IndexTable->Length is used as index in array IndexTable->Index[].
> So IndexTable->Length needs to be checked, which should be less than
> the array size.
> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
>  MdeModulePkg/Universal/Variable/Pei/Variable.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c
> b/MdeModulePkg/Universal/Variable/Pei/Variable.c
> index 715802f33c29..f61465fc3045 100644
> --- a/MdeModulePkg/Universal/Variable/Pei/Variable.c
> +++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c
> @@ -896,7 +896,7 @@ FindVariableEx (
>        //
>        if ((IndexTable != NULL) && !StopRecord) {
>          Offset = (UINTN) Variable - (UINTN) LastVariable;
> -        if ((Offset > 0x0FFFF) || (IndexTable->Length == sizeof (IndexTable->Index)
> / sizeof (IndexTable->Index[0]))) {
> +        if ((Offset > 0x0FFFF) || (IndexTable->Length >= sizeof (IndexTable-
> >Index) / sizeof (IndexTable->Index[0]))) {


Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


>            //
>            // Stop to record if the distance of two neighbouring VAR_ADDED
> variable is larger than the allowable scope(UINT16),
>            // or the record buffer is full.
> --
> 2.18.0.windows.1


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

end of thread, other threads:[~2019-10-30  6:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-17  3:19 [PATCH] MdeModulePkg/Variable/Pei: Update the condition in if statement Zhang, Shenglei
2019-10-30  6:51 ` Wu, Hao A

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