Reviewed-by: Jaben Carsey <jaben.car...@intel.com>

> -----Original Message-----
> From: Qiu, Shumin
> Sent: Tuesday, September 08, 2015 12:05 AM
> To: edk2-devel@lists.01.org
> Cc: Qiu, Shumin <shumin....@intel.com>; Carsey, Jaben
> <jaben.car...@intel.com>; Gao, Liming <liming....@intel.com>
> Subject: [PATCH] MdePkg: Refine UefiFileHandleLib to avoid write non-ASCII
> char into ASCII file.
> Importance: High
> 
> Cc: Jaben Carsey <jaben.car...@intel.com>
> Cc: Liming Gao <liming....@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Qiu Shumin <shumin....@intel.com>
> ---
>  MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
> b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
> index 04a2f18..dfec5fa 100644
> --- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
> +++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
> @@ -1079,6 +1079,7 @@ FileHandleWriteLine(
>    EFI_STATUS  Status;
>    CHAR16      CharBuffer;
>    UINTN       Size;
> +  UINTN       Index;
>    UINTN       CharSize;
>    UINT64      FileSize;
>    UINT64      OriginalFilePosition;
> @@ -1136,6 +1137,12 @@ FileHandleWriteLine(
>        return EFI_OUT_OF_RESOURCES;
>      }
>      UnicodeStrToAsciiStr (Buffer, AsciiBuffer);
> +    for (Index = 0; Index < Size; Index++) {
> +      if (!((AsciiBuffer[Index] >= 0) && (AsciiBuffer[Index] < 128))){
> +        FreePool(AsciiBuffer);
> +        return EFI_INVALID_PARAMETER;
> +      }
> +    }
> 
>      Size = AsciiStrSize(AsciiBuffer) - sizeof(CHAR8);
>      Status = FileHandleWrite(Handle, &Size, AsciiBuffer);
> --
> 1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to