Reviewed-by: Jaben Carsey <[email protected]> > -----Original Message----- > From: Qiu, Shumin > Sent: Tuesday, September 08, 2015 12:05 AM > To: [email protected] > Cc: Qiu, Shumin <[email protected]>; Carsey, Jaben > <[email protected]>; Gao, Liming <[email protected]> > Subject: [PATCH] MdePkg: Refine UefiFileHandleLib to avoid write non-ASCII > char into ASCII file. > Importance: High > > Cc: Jaben Carsey <[email protected]> > Cc: Liming Gao <[email protected]> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Qiu Shumin <[email protected]> > --- > 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 [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

