]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/EfiUtilityMsgs.c
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / C / Common / EfiUtilityMsgs.c
index 5496a439e279989776c09d8c3d5dccd11f8b3402..f8d2a40be1e19a29149378157c26595cfd74b269 100644 (file)
@@ -2,13 +2,7 @@
 EFI tools utility functions to display warning, error, and informational messages\r
 \r
 Copyright (c) 2004 - 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 --*/\r
 \r
@@ -21,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "EfiUtilityMsgs.h"\r
 \r
 //\r
-// Declare module globals for keeping track of the the utility's\r
+// Declare module globals for keeping track of the utility's\r
 // name and other settings.\r
 //\r
 STATIC STATUS mStatus                 = STATUS_SUCCESS;\r
@@ -61,7 +55,7 @@ Arguments:
   at least something valid is not specified.\r
 \r
   FileName - name of the file or application. If not specified, then the\r
-             utilty name (as set by the utility calling SetUtilityName()\r
+             utility name (as set by the utility calling SetUtilityName()\r
              earlier) is used. Otherwise "Unknown utility" is used.\r
 \r
   LineNumber - the line number of error, typically used by parsers. If the\r
@@ -384,7 +378,7 @@ Routine Description:
 Arguments:\r
   Type        - "warning" or "error" string to insert into the message to be\r
                 printed. The first character of this string (converted to uppercase)\r
-                is used to preceed the MessageCode value in the output string.\r
+                is used to precede the MessageCode value in the output string.\r
 \r
   FileName    - name of the file where the warning was detected, or the name\r
                 of the application that detected the warning\r
@@ -462,10 +456,11 @@ Notes:
                        );\r
     }\r
     if (Cptr != NULL) {\r
-      sprintf (Line, ": %s", Cptr);\r
+      strcpy (Line, ": ");\r
+      strncat (Line, Cptr, MAX_LINE_LEN - strlen (Line) - 1);\r
       if (LineNumber != 0) {\r
         sprintf (Line2, "(%u)", (unsigned) LineNumber);\r
-        strcat (Line, Line2);\r
+        strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);\r
       }\r
     }\r
   } else {\r
@@ -476,14 +471,16 @@ Notes:
       if (mUtilityName[0] != '\0') {\r
         fprintf (stdout, "%s...\n", mUtilityName);\r
       }\r
-      sprintf (Line, "%s", Cptr);\r
+      strncpy (Line, Cptr, MAX_LINE_LEN - 1);\r
+      Line[MAX_LINE_LEN - 1] = 0;\r
       if (LineNumber != 0) {\r
         sprintf (Line2, "(%u)", (unsigned) LineNumber);\r
-        strcat (Line, Line2);\r
+        strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);\r
       }\r
     } else {\r
       if (mUtilityName[0] != '\0') {\r
-        sprintf (Line, "%s", mUtilityName);\r
+        strncpy (Line, mUtilityName, MAX_LINE_LEN - 1);\r
+        Line[MAX_LINE_LEN - 1] = 0;\r
       }\r
     }\r
 \r
@@ -501,12 +498,12 @@ Notes:
   // Have to print an error code or Visual Studio won't find the\r
   // message for you. It has to be decimal digits too.\r
   //\r
+  strncat (Line, ": ", MAX_LINE_LEN - strlen (Line) - 1);\r
+  strncat (Line, Type, MAX_LINE_LEN - strlen (Line) - 1);\r
   if (MessageCode != 0) {\r
-    sprintf (Line2, ": %s %04u", Type, (unsigned) MessageCode);\r
-  } else {\r
-    sprintf (Line2, ": %s", Type);\r
+    sprintf (Line2, " %04u", (unsigned) MessageCode);\r
+    strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);\r
   }\r
-  strcat (Line, Line2);\r
   fprintf (stdout, "%s", Line);\r
   //\r
   // If offending text was provided, then print it\r
@@ -594,7 +591,7 @@ Routine Description:
 \r
 Arguments:\r
   UtilityName  -  name of the utility, which will be printed with all\r
-                  error/warning/debug messags.\r
+                  error/warning/debug messages.\r
 \r
 Returns:\r
   NA\r