summaryrefslogtreecommitdiff
path: root/MdePkg
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-09-10 05:24:32 +0000
committerhwu1225 <hwu1225@Edk2>2015-09-10 05:24:32 +0000
commit6c6967d4a6073313fe7b53b881eaba6014c7f72b (patch)
treee92797a3284ec5a8bcf5ccb5c15bc1a5fa0251ba /MdePkg
parentc9d0fe0817a87313a28b800e001ecf2b5d4bbb5a (diff)
downloadedk2-platforms-6c6967d4a6073313fe7b53b881eaba6014c7f72b.tar.xz
MdePkg: Refine UefiFileHandleLib to avoid write non-ASCII char into ASCII file.
(Sync patch r18430 from main trunk.) Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@18432 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
index 04a2f189ec..dfec5fa4d4 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);