FoundVarName = AllocateZeroPool (NameSize);\r
if (FoundVarName != NULL) {\r
if (PrevName != NULL) {\r
- StrCpy(FoundVarName, PrevName);\r
+ StrnCpy(FoundVarName, PrevName, NameSize/sizeof(CHAR16)-1);\r
}\r
\r
Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);\r
Build a table, each item is (Key, Info) pair.\r
And give a interface of query a string out of a table.\r
\r
- Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2005 - 2014, 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
for (Index = 0; Index < Number; Index++) {\r
High = (UINT8) (Table[Index].Key >> 8);\r
Low = (UINT8) (Table[Index].Key & 0x00FF);\r
+\r
//\r
// Check if Key is in the range\r
+ // or if Key == Value in the table\r
//\r
- if (High > Low && Key >= Low && Key <= High) {\r
- StrnCpy (Info, Table[Index].Info, InfoLen-1);\r
- StrnCat (Info, L"\n", InfoLen - StrLen(Info));\r
- return Key;\r
- }\r
- //\r
- // Check if Key == Value in the table\r
- //\r
- if (Table[Index].Key == Key) {\r
+ if ((High > Low && Key >= Low && Key <= High) \r
+ || (Table[Index].Key == Key)) {\r
StrnCpy (Info, Table[Index].Info, InfoLen-1);\r
- StrnCat (Info, L"\n", InfoLen - StrLen(Info));\r
+ StrnCat (Info, L"\n", InfoLen - 1 - StrLen(Info));\r
return Key;\r
}\r
}\r
\r
- StrnCpy (Info, L"Undefined Value\n", InfoLen);\r
+ StrnCpy (Info, L"Undefined Value\n", InfoLen - 1);\r
return QUERY_TABLE_UNFOUND;\r
}\r
\r