[edk2-devel] [PATCH v3 4/4] MdeModulePkg/SetupBrowserDxe: ASSERT GetBufferForValue(&Value)

Zhang, Shenglei posted 4 patches 6 years, 3 months ago
[edk2-devel] [PATCH v3 4/4] MdeModulePkg/SetupBrowserDxe: ASSERT GetBufferForValue(&Value)
Posted by Zhang, Shenglei 6 years, 3 months ago
Before called by GetBufferForValue(), Value has already been called
function IsTypeInBuffer to make sure the value must be buffer type.
So GetBufferForValue can not return NULL.
This commit adds ASSERT to assume (GetBufferForValue (&Value) is not
NULL.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---

v3: Add ASSERT instead of using error handling.

 MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
index 7f4929c2fcd9..138912e00823 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
@@ -1281,7 +1281,10 @@ IfrToUint (
       Result->Type = EFI_IFR_TYPE_UNDEFINED;
       return EFI_SUCCESS;
     }
+
+    ASSERT ((GetBufferForValue (&Value) != NULL);
     Result->Value.u64 = *(UINT64*) GetBufferForValue (&Value);
+
     if (Value.Type == EFI_IFR_TYPE_BUFFER) {
       FreePool (Value.Buffer);
     }
-- 
2.18.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49798): https://edk2.groups.io/g/devel/message/49798
Mute This Topic: https://groups.io/mt/40403790/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v3 4/4] MdeModulePkg/SetupBrowserDxe: ASSERT GetBufferForValue(&Value)
Posted by Dandan Bi 6 years, 3 months ago
Reviewed-by: Dandan Bi <dandan.bi@intel.com>

Thanks,
Dandan

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Zhang, Shenglei
> Sent: Friday, November 1, 2019 2:14 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> Subject: [edk2-devel] [PATCH v3 4/4] MdeModulePkg/SetupBrowserDxe:
> ASSERT GetBufferForValue(&Value)
> 
> Before called by GetBufferForValue(), Value has already been called function
> IsTypeInBuffer to make sure the value must be buffer type.
> So GetBufferForValue can not return NULL.
> This commit adds ASSERT to assume (GetBufferForValue (&Value) is not
> NULL.
> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
> 
> v3: Add ASSERT instead of using error handling.
> 
>  MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
> b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
> index 7f4929c2fcd9..138912e00823 100644
> --- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
> +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
> @@ -1281,7 +1281,10 @@ IfrToUint (
>        Result->Type = EFI_IFR_TYPE_UNDEFINED;
>        return EFI_SUCCESS;
>      }
> +
> +    ASSERT ((GetBufferForValue (&Value) != NULL);
>      Result->Value.u64 = *(UINT64*) GetBufferForValue (&Value);
> +
>      if (Value.Type == EFI_IFR_TYPE_BUFFER) {
>        FreePool (Value.Buffer);
>      }
> --
> 2.18.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49945): https://edk2.groups.io/g/devel/message/49945
Mute This Topic: https://groups.io/mt/40403790/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-