]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c
Add more check to make sure code run safely.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / Graphics / Unicode / Sprint.c
index 3eb6c85b8aa11caa299adedbd35c907ba2e36761..de99ee07ea3b36202747c94c3aaad807ed426d02 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -123,8 +123,8 @@ Returns:
 --*/\r
 {\r
   UINTN   Index;\r
-  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
-  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
+  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
 \r
   for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
     UnicodeFormat[Index] = (CHAR16) FormatString[Index];\r
@@ -132,7 +132,7 @@ Returns:
 \r
   UnicodeFormat[Index]  = '\0';\r
 \r
-  Index                 = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);\r
+  Index                 = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);\r
 \r
   for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {\r
     Buffer[Index] = (CHAR8) UnicodeResult[Index];\r