summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-09-10 02:45:30 +0000
committershenshushi <shenshushi@Edk2>2015-09-10 02:45:30 +0000
commit1cdc35c42ca35c6b66ea28109c3ad690ef622b82 (patch)
tree5e2ce21e894cdafcf372a7843c9a4c09cb0941f6 /MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
parent78c8ec8a3f1c09856f0d70027d6a9d814208a77f (diff)
downloadedk2-1cdc35c42ca35c6b66ea28109c3ad690ef622b82.tar.gz
edk2-1cdc35c42ca35c6b66ea28109c3ad690ef622b82.tar.bz2
edk2-1cdc35c42ca35c6b66ea28109c3ad690ef622b82.zip
MdePkg: Refine UefiFileHandleLib to avoid write non-ASCII char into ASCII file.
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/trunk/edk2@18430 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c')
-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);