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
#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
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
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
);\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
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
// 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
\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