]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
MdeModulePkg/PrintLib: Add missing return status check for Print APIs
[mirror_edk2.git] / MdeModulePkg / Library / DxePrintLibPrint2Protocol / PrintLib.c
index 4acdcb8714903a165dcaa1069ab8f612a7efd639..01378687fd58e7303c0c42bfc946eace70ed6cd9 100644 (file)
@@ -6,7 +6,7 @@
   protocol related to this implementation, not in the public spec. So, this \r
   library instance is only for this code base.\r
 \r
-Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 2017, 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
@@ -71,7 +71,8 @@ PrintLibConstructor (
   @param  BaseListMarker  BASE_LIST style variable argument list consumed by processing Format.\r
   @param  Size            The size, in bytes, of the BaseListMarker buffer.\r
 \r
-  @return The number of bytes in BaseListMarker.  0 if BaseListMarker is too small.\r
+  @return TRUE   The VA_LIST has been converted to BASE_LIST.\r
+  @return FALSE  The VA_LIST has not been converted to BASE_LIST.\r
 \r
 **/\r
 BOOLEAN\r
@@ -205,6 +206,7 @@ DxePrintLibPrint2ProtocolVaListToBaseList (
     // If BASE_LIST is larger than Size, then return FALSE\r
     //\r
     if ((UINTN)((UINT8 *)BaseListMarker - (UINT8 *)BaseListStart) > Size) {\r
+      DEBUG ((DEBUG_ERROR, "The input variable argument list is too long. Please consider breaking into multiple print calls.\n"));\r
       return FALSE;\r
     }\r
 \r
@@ -264,15 +266,19 @@ UnicodeVSPrint (
   IN  VA_LIST       Marker\r
   )\r
 {\r
-  UINT64  BaseListMarker[256 / sizeof (UINT64)];\r
-\r
-  DxePrintLibPrint2ProtocolVaListToBaseList (\r
-    FALSE, \r
-    (CHAR8 *)FormatString, \r
-    Marker, \r
-    (BASE_LIST)BaseListMarker, \r
-    sizeof (BaseListMarker) - 8\r
-    );\r
+  UINT64   BaseListMarker[256 / sizeof (UINT64)];\r
+  BOOLEAN  Converted;\r
+\r
+  Converted = DxePrintLibPrint2ProtocolVaListToBaseList (\r
+                FALSE,\r
+                (CHAR8 *)FormatString,\r
+                Marker,\r
+                (BASE_LIST)BaseListMarker,\r
+                sizeof (BaseListMarker) - 8\r
+                );\r
+  if (!Converted) {\r
+    return 0;\r
+  }\r
 \r
   return UnicodeBSPrint (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);\r
 }\r
@@ -417,15 +423,19 @@ UnicodeVSPrintAsciiFormat (
   IN  VA_LIST      Marker\r
   )\r
 {\r
-  UINT64  BaseListMarker[256 / sizeof (UINT64)];\r
-\r
-  DxePrintLibPrint2ProtocolVaListToBaseList (\r
-    TRUE, \r
-    FormatString, \r
-    Marker, \r
-    (BASE_LIST)BaseListMarker, \r
-    sizeof (BaseListMarker) - 8\r
-    );\r
+  UINT64   BaseListMarker[256 / sizeof (UINT64)];\r
+  BOOLEAN  Converted;\r
+\r
+  Converted = DxePrintLibPrint2ProtocolVaListToBaseList (\r
+                TRUE,\r
+                FormatString,\r
+                Marker,\r
+                (BASE_LIST)BaseListMarker,\r
+                sizeof (BaseListMarker) - 8\r
+                );\r
+  if (!Converted) {\r
+    return 0;\r
+  }\r
 \r
   return UnicodeBSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);\r
 }\r
@@ -621,15 +631,19 @@ AsciiVSPrint (
   IN  VA_LIST       Marker\r
   )\r
 {\r
-  UINT64  BaseListMarker[256 / sizeof (UINT64)];\r
-\r
-  DxePrintLibPrint2ProtocolVaListToBaseList (\r
-    TRUE, \r
-    FormatString, \r
-    Marker, \r
-    (BASE_LIST)BaseListMarker, \r
-    sizeof (BaseListMarker) - 8\r
-    );\r
+  UINT64   BaseListMarker[256 / sizeof (UINT64)];\r
+  BOOLEAN  Converted;\r
+\r
+  Converted = DxePrintLibPrint2ProtocolVaListToBaseList (\r
+                TRUE,\r
+                FormatString,\r
+                Marker,\r
+                (BASE_LIST)BaseListMarker,\r
+                sizeof (BaseListMarker) - 8\r
+                );\r
+  if (!Converted) {\r
+    return 0;\r
+  }\r
 \r
   return AsciiBSPrint (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);\r
 }\r
@@ -771,15 +785,19 @@ AsciiVSPrintUnicodeFormat (
   IN  VA_LIST       Marker\r
   )\r
 {\r
-  UINT64  BaseListMarker[256 / sizeof (UINT64)];\r
-\r
-  DxePrintLibPrint2ProtocolVaListToBaseList (\r
-    FALSE, \r
-    (CHAR8 *)FormatString, \r
-    Marker, \r
-    (BASE_LIST)BaseListMarker, \r
-    sizeof (BaseListMarker) - 8\r
-    );\r
+  UINT64   BaseListMarker[256 / sizeof (UINT64)];\r
+  BOOLEAN  Converted;\r
+\r
+  Converted = DxePrintLibPrint2ProtocolVaListToBaseList (\r
+                FALSE,\r
+                (CHAR8 *)FormatString,\r
+                Marker,\r
+                (BASE_LIST)BaseListMarker,\r
+                sizeof (BaseListMarker) - 8\r
+                );\r
+  if (!Converted) {\r
+    return 0;\r
+  }\r
 \r
   return AsciiBSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker);\r
 }\r