]> git.proxmox.com Git - mirror_edk2.git/commitdiff
This patch replaces StrCpy with StrnCpy or refactors out the usage of StrCpy through...
authorJaben Carsey <jaben.carsey@intel.com>
Fri, 29 Aug 2014 21:57:42 +0000 (21:57 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 29 Aug 2014 21:57:42 +0000 (21:57 +0000)
This patch replaces StrCat with StrnCat or refactors out the usage of StrCat through some other means.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16004 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c
ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c

index 0eee944ed4296f97b808f7a5c9571b3dd5ea6589..e8c2904823bd06c41424e3c0e98bb250c7322a8a 100644 (file)
@@ -406,7 +406,7 @@ CascadeProcessVariables (
     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
index be8b7c6c5360471a0e29d251092711675e5c324f..700592d2630c64f61c46338ab6b7900d49023f74 100644 (file)
@@ -2,7 +2,7 @@
   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
@@ -3214,25 +3214,20 @@ QueryTable (
   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