[edk2] [PATCH 2/2] MdePkg/UefiDevicePathLib: Add a checking step

Gao, Liming liming.gao at intel.com
Mon Dec 10 22:44:19 PST 2018


Shenglei:
  Please update IsDevicePathValid() API description in MdePkg\Include\Library\DevicePathLib.h, and also remove ASSERT (DevicePath != NULL); in function implementation.

Thanks
Liming
> -----Original Message-----
> From: Zhang, Shenglei
> Sent: Tuesday, December 11, 2018 2:31 PM
> To: edk2-devel at lists.01.org
> Cc: Gao, Liming <liming.gao at intel.com>; Kinney, Michael D <michael.d.kinney at intel.com>
> Subject: [PATCH 2/2] MdePkg/UefiDevicePathLib: Add a checking step
> 
> Add a checking step in DevicePathUtilities.c to verify DevicePath.
> 
> Cc: Liming Gao <liming.gao at intel.com>
> Cc: Michael D Kinney <michael.d.kinney at intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Shenglei Zhang <shenglei.zhang at intel.com>
> ---
>  .../Library/UefiDevicePathLib/DevicePathUtilities.c  | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> index 665e5a4adc..f29e1e22f6 100644
> --- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> @@ -59,6 +59,18 @@ IsDevicePathValid (
>    UINTN Size;
>    UINTN NodeLength;
> 
> +/**
> +  NULL device path is also invalid path.
> +
> +  IsDevicePathValid() should return FALSE or TRUE, and not ASSERT().
> +
> +  This change needs to update IsDevicePathValid() API definition and implementation both.
> +
> +**/
> +  if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) {
> +    return FALSE;
> +  }
> +
>    ASSERT (DevicePath != NULL);
> 
>    if (MaxSize == 0) {
> --
> 2.18.0.windows.1



More information about the edk2-devel mailing list