Revision: 18432
          http://sourceforge.net/p/edk2/code/18432
Author:   hwu1225
Date:     2015-09-10 05:24:32 +0000 (Thu, 10 Sep 2015)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/18430

Modified Paths:
--------------
    branches/UDK2015/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c

Modified: branches/UDK2015/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
===================================================================
--- branches/UDK2015/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c       
2015-09-10 03:08:56 UTC (rev 18431)
+++ branches/UDK2015/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c       
2015-09-10 05:24:32 UTC (rev 18432)
@@ -1079,6 +1079,7 @@
   EFI_STATUS  Status;
   CHAR16      CharBuffer;
   UINTN       Size;
+  UINTN       Index;
   UINTN       CharSize;
   UINT64      FileSize;
   UINT64      OriginalFilePosition;
@@ -1136,6 +1137,12 @@
       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);


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to