/** @file\r
Common basic Library Functions\r
\r
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\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
//\r
RootPath = getcwd (NULL, 0);\r
if (RootPath != NULL) {\r
- strcat (mCommonLibFullPath, RootPath);\r
+ if (strlen (mCommonLibFullPath) + strlen (RootPath) > MAX_LONG_FILE_PATH - 1) {\r
+ Error (NULL, 0, 2000, "Invalid parameter", "RootPath is too long!");\r
+ free (RootPath);\r
+ return NULL;\r
+ }\r
+ strncat (mCommonLibFullPath, RootPath, MAX_LONG_FILE_PATH - strlen (mCommonLibFullPath) - 1);\r
if (FileName[0] != '\\' && FileName[0] != '/') {\r
+ if (strlen (mCommonLibFullPath) + 1 > MAX_LONG_FILE_PATH - 1) {\r
+ Error (NULL, 0, 2000, "Invalid parameter", "RootPath is too long!");\r
+ free (RootPath);\r
+ return NULL;\r
+ }\r
//\r
// Attach directory separator\r
//\r
- strcat (mCommonLibFullPath, "\\");\r
+ strncat (mCommonLibFullPath, "\\", MAX_LONG_FILE_PATH - strlen (mCommonLibFullPath) - 1);\r
}\r
free (RootPath);\r
}\r
//\r
if ((PathPointer = strstr (mCommonLibFullPath, ":\\\\")) != NULL) {\r
*(PathPointer + 2) = '\0';\r
- strcat (mCommonLibFullPath, PathPointer + 3);\r
+ strncat (mCommonLibFullPath, PathPointer + 3, MAX_LONG_FILE_PATH - strlen (mCommonLibFullPath) - 1);\r
}\r
\r
//\r
//\r
while ((PathPointer = strstr (mCommonLibFullPath, ".\\")) != NULL) {\r
*PathPointer = '\0';\r
- strcat (mCommonLibFullPath, PathPointer + 2);\r
+ strncat (mCommonLibFullPath, PathPointer + 2, MAX_LONG_FILE_PATH - strlen (mCommonLibFullPath) - 1);\r
}\r
\r
//\r
//\r
while ((PathPointer = strstr (mCommonLibFullPath, "\\.\\")) != NULL) {\r
*PathPointer = '\0';\r
- strcat (mCommonLibFullPath, PathPointer + 2);\r
+ strncat (mCommonLibFullPath, PathPointer + 2, MAX_LONG_FILE_PATH - strlen (mCommonLibFullPath) - 1);\r
}\r
\r
//\r
// Skip one directory\r
//\r
*PathPointer = '\0';\r
- strcat (mCommonLibFullPath, NextPointer);\r
+ strncat (mCommonLibFullPath, NextPointer, MAX_LONG_FILE_PATH - strlen (mCommonLibFullPath) - 1);\r
} else {\r
//\r
// No directory is found. Just break.\r
/** @file\r
EFI tools utility functions to display warning, error, and informational messages\r
\r
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\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
if (UtilityName != NULL) {\r
if (strlen (UtilityName) >= sizeof (mUtilityName)) {\r
Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size");\r
- strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1);\r
- mUtilityName[sizeof (mUtilityName) - 1] = 0;\r
- return ;\r
- } else {\r
- strcpy (mUtilityName, UtilityName);\r
}\r
+ strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1);\r
+ mUtilityName[sizeof (mUtilityName) - 1] = 0;\r
} else {\r
Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name");\r
}\r