]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Universal/Variable: Use safe string functions to refine code.
authorQiu Shumin <shumin.qiu@intel.com>
Wed, 1 Jul 2015 08:34:22 +0000 (08:34 +0000)
committershenshushi <shenshushi@Edk2>
Wed, 1 Jul 2015 08:34:22 +0000 (08:34 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17789 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c

index e0768404f9fc61c3fdd02b3a0a38a38102f6be38..977332e1cf4999a58ded7276f2bcc2d9c92e13ea 100644 (file)
@@ -3,7 +3,7 @@
   Emulation Variable services operate on the runtime volatile memory.\r
   The nonvolatile variable space doesn't exist.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 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
@@ -322,7 +322,7 @@ UpdateVariableInfo (
       CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);\r
       gVariableInfo->Name = AllocateZeroPool (StrSize (VariableName));\r
       ASSERT (gVariableInfo->Name != NULL);\r
-      StrnCpy (gVariableInfo->Name, VariableName, StrLen (VariableName));\r
+      StrCpyS (gVariableInfo->Name, StrSize(VariableName)/sizeof(CHAR16), VariableName);\r
       gVariableInfo->Volatile = Volatile;\r
 \r
       gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);\r
@@ -360,7 +360,7 @@ UpdateVariableInfo (
         CopyGuid (&Entry->Next->VendorGuid, VendorGuid);\r
         Entry->Next->Name = AllocateZeroPool (StrSize (VariableName));\r
         ASSERT (Entry->Next->Name != NULL);\r
-        StrnCpy (Entry->Next->Name, VariableName, StrLen (VariableName));\r
+        StrCpyS (Entry->Next->Name, StrSize(VariableName)/sizeof(CHAR16), VariableName);\r
         Entry->Next->Volatile = Volatile;\r
       }\r
 \r
index ab0c1d6324a0da0f1d32cfdf480773d12a458461..61de47d3578f44da96be4f5e155614abfdaad62c 100644 (file)
@@ -1046,7 +1046,7 @@ InternalVarCheckVariablePropertySet (
       goto Done;\r
     }\r
     VariableName = (CHAR16 *) ((UINTN) Entry + sizeof (*Entry));\r
-    StrnCpy (VariableName, Name, StrLen (Name));\r
+    StrCpyS (VariableName, StrSize(Name)/sizeof(CHAR16), Name);\r
     CopyGuid (&Entry->Guid, Guid);\r
     CopyMem (&Entry->VariableProperty, VariableProperty, sizeof (*VariableProperty));\r
     InsertTailList (&mVarCheckVariableList, &Entry->Link);\r
index 70be71e7c76237dd6e454c66e777271e76d3f7dd..e1dfeeaa031d0bb98b8c77d956ababefd523efdb 100644 (file)
@@ -158,7 +158,7 @@ UpdateVariableInfo (
       CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);\r
       gVariableInfo->Name = AllocateZeroPool (StrSize (VariableName));\r
       ASSERT (gVariableInfo->Name != NULL);\r
-      StrnCpy (gVariableInfo->Name, VariableName, StrLen (VariableName));\r
+      StrCpyS (gVariableInfo->Name, StrSize(VariableName)/sizeof(CHAR16), VariableName);\r
       gVariableInfo->Volatile = Volatile;\r
     }\r
 \r
@@ -194,7 +194,7 @@ UpdateVariableInfo (
         CopyGuid (&Entry->Next->VendorGuid, VendorGuid);\r
         Entry->Next->Name = AllocateZeroPool (StrSize (VariableName));\r
         ASSERT (Entry->Next->Name != NULL);\r
-        StrnCpy (Entry->Next->Name, VariableName, StrLen (VariableName));\r
+        StrCpyS (Entry->Next->Name, StrSize(VariableName)/sizeof(CHAR16), VariableName);\r
         Entry->Next->Volatile = Volatile;\r
       }\r
 \r
@@ -2853,7 +2853,7 @@ VariableLockRequestToLock (
   }\r
 \r
   Name = (CHAR16 *) ((UINTN) Entry + sizeof (*Entry));\r
-  StrnCpy   (Name, VariableName, StrLen (VariableName));\r
+  StrCpyS (Name, StrSize (VariableName)/sizeof(CHAR16), VariableName);\r
   CopyGuid (&Entry->Guid, VendorGuid);\r
   InsertTailList (&mLockedVariableList, &Entry->Link);\r
 \r