\r
Boot option manipulation\r
\r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, 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
StringSize = StrSize((UINT16*)LoadOptionPtr);\r
\r
- NewLoadContext->Description = AllocateZeroPool (StrSize((UINT16*)LoadOptionPtr));\r
- ASSERT (NewLoadContext->Description != NULL);\r
- StrCpy (NewLoadContext->Description, (UINT16*)LoadOptionPtr);\r
- \r
+ NewLoadContext->Description = AllocateCopyPool (StrSize((UINT16*)LoadOptionPtr), LoadOptionPtr);\r
ASSERT (NewLoadContext->Description != NULL);\r
+\r
NewMenuEntry->DisplayString = NewLoadContext->Description;\r
\r
LoadOptionPtr += StringSize;\r
{\r
UINTN Size1;\r
UINTN Size2;\r
+ UINTN MaxLen;\r
CHAR16 *Str;\r
CHAR16 *TmpStr;\r
CHAR16 *Ptr;\r
\r
Size1 = StrSize (Str1);\r
Size2 = StrSize (Str2);\r
- Str = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));\r
+ MaxLen = (Size1 + Size2 + sizeof (CHAR16)) / sizeof (CHAR16);\r
+ Str = AllocateCopyPool (MaxLen * sizeof (CHAR16), Str1);\r
ASSERT (Str != NULL);\r
\r
- TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16)); \r
+ TmpStr = AllocateZeroPool (MaxLen * sizeof (CHAR16)); \r
ASSERT (TmpStr != NULL);\r
\r
- StrCat (Str, Str1);\r
if (!((*Str == '\\') && (*(Str + 1) == 0))) {\r
- StrCat (Str, L"\\");\r
+ StrCatS (Str, MaxLen, L"\\");\r
}\r
\r
- StrCat (Str, Str2);\r
+ StrCatS (Str, MaxLen, Str2);\r
\r
Ptr = Str;\r
LastSlash = Str;\r
//\r
\r
//\r
- // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings \r
+ // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings \r
// that overlap.\r
//\r
- StrCpy (TmpStr, Ptr + 3);\r
- StrCpy (LastSlash, TmpStr);\r
+ StrCpyS (TmpStr, MaxLen, Ptr + 3);\r
+ StrCpyS (LastSlash, MaxLen - (UINTN) (LastSlash - Str), TmpStr);\r
Ptr = LastSlash;\r
} else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {\r
//\r
//\r
\r
//\r
- // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings \r
+ // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings \r
// that overlap.\r
//\r
- StrCpy (TmpStr, Ptr + 2);\r
- StrCpy (Ptr, TmpStr);\r
+ StrCpyS (TmpStr, MaxLen, Ptr + 2);\r
+ StrCpyS (Ptr, MaxLen - (UINTN) (Ptr - Str), TmpStr);\r
Ptr = LastSlash;\r
} else if (*Ptr == '\\') {\r
LastSlash = Ptr;\r
/** @file\r
Formset guids, form id and VarStore data structure for Boot Maintenance Manager.\r
\r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, 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
#define KEY_VALUE_SAVE_AND_EXIT_DRIVER 0x1002\r
#define KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER 0x1003\r
\r
+//\r
+// Description data and optional data size\r
+//\r
+#define DESCRIPTION_DATA_SIZE 75\r
+#define OPTIONAL_DATA_SIZE 127\r
+\r
///\r
/// This is the data structure used by File Explorer formset\r
///\r
typedef struct {\r
- UINT16 BootDescriptionData[75];\r
- UINT16 BootOptionalData[127];\r
- UINT16 DriverDescriptionData[75];\r
- UINT16 DriverOptionalData[127];\r
+ UINT16 BootDescriptionData[DESCRIPTION_DATA_SIZE];\r
+ UINT16 BootOptionalData[OPTIONAL_DATA_SIZE];\r
+ UINT16 DriverDescriptionData[DESCRIPTION_DATA_SIZE];\r
+ UINT16 DriverOptionalData[OPTIONAL_DATA_SIZE];\r
BOOLEAN BootOptionChanged;\r
BOOLEAN DriverOptionChanged;\r
UINT8 Active;\r
/** @file\r
Dynamically update the pages.\r
\r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, 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
UnicodeValueToString (ModeString, 0, Col, 0);\r
PStr = &ModeString[0];\r
- StrnCat (PStr, L" x ", StrLen(L" x ") + 1);\r
+ StrCatS (PStr, sizeof (ModeString) / sizeof (ModeString[0]), L" x ");\r
PStr = PStr + StrLen (PStr);\r
UnicodeValueToString (PStr , 0, Row, 0);\r
\r
/** @file\r
Variable operation that will be used by bootmaint\r
\r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, 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
\r
if (*DescriptionData == 0x0000) {\r
- StrCpy (DescriptionData, DriverString);\r
+ StrCpyS (DescriptionData, DESCRIPTION_DATA_SIZE, DriverString);\r
}\r
\r
BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescriptionData);\r
UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", Index);\r
\r
if (NvRamMap->BootDescriptionData[0] == 0x0000) {\r
- StrCpy (NvRamMap->BootDescriptionData, BootString);\r
+ StrCpyS (\r
+ NvRamMap->BootDescriptionData,\r
+ sizeof (NvRamMap->BootDescriptionData) / sizeof (NvRamMap->BootDescriptionData[0]),\r
+ BootString\r
+ );\r
}\r
\r
BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (NvRamMap->BootDescriptionData);\r