]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Refine UefiFileHandleLib to avoid write non-ASCII char into ASCII file.
authorQiu Shumin <shumin.qiu@intel.com>
Thu, 10 Sep 2015 02:45:30 +0000 (02:45 +0000)
committershenshushi <shenshushi@Edk2>
Thu, 10 Sep 2015 02:45:30 +0000 (02:45 +0000)
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

MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c

index 04a2f189eceb0c650c3d632a2949898338c3e5ae..dfec5fa4d47d0917389ab9b0e398eaa9fa96da21 100644 (file)
@@ -1079,6 +1079,7 @@ FileHandleWriteLine(
   EFI_STATUS  Status;\r
   CHAR16      CharBuffer;\r
   UINTN       Size;\r
+  UINTN       Index;\r
   UINTN       CharSize;\r
   UINT64      FileSize;\r
   UINT64      OriginalFilePosition;\r
@@ -1136,6 +1137,12 @@ FileHandleWriteLine(
       return EFI_OUT_OF_RESOURCES;\r
     }\r
     UnicodeStrToAsciiStr (Buffer, AsciiBuffer);\r
+    for (Index = 0; Index < Size; Index++) {\r
+      if (!((AsciiBuffer[Index] >= 0) && (AsciiBuffer[Index] < 128))){\r
+        FreePool(AsciiBuffer);\r
+        return EFI_INVALID_PARAMETER;\r
+      }\r
+    }\r
     \r
     Size = AsciiStrSize(AsciiBuffer) - sizeof(CHAR8);\r
     Status = FileHandleWrite(Handle, &Size, AsciiBuffer);\r