Revision: 17789
          http://sourceforge.net/p/edk2/code/17789
Author:   shenshushi
Date:     2015-07-01 08:34:22 +0000 (Wed, 01 Jul 2015)
Log Message:
-----------
MdeModulePkg/Universal/Variable: Use safe string functions to refine code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <[email protected]>
Reviewed-by: Star Zeng <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
    trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
    trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c

Modified: trunk/edk2/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c      
2015-07-01 08:32:29 UTC (rev 17788)
+++ trunk/edk2/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c      
2015-07-01 08:34:22 UTC (rev 17789)
@@ -3,7 +3,7 @@
   Emulation Variable services operate on the runtime volatile memory.
   The nonvolatile variable space doesn't exist.
 
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -322,7 +322,7 @@
       CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);
       gVariableInfo->Name = AllocateZeroPool (StrSize (VariableName));
       ASSERT (gVariableInfo->Name != NULL);
-      StrnCpy (gVariableInfo->Name, VariableName, StrLen (VariableName));
+      StrCpyS (gVariableInfo->Name, StrSize(VariableName)/sizeof(CHAR16), 
VariableName);
       gVariableInfo->Volatile = Volatile;
 
       gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);
@@ -360,7 +360,7 @@
         CopyGuid (&Entry->Next->VendorGuid, VendorGuid);
         Entry->Next->Name = AllocateZeroPool (StrSize (VariableName));
         ASSERT (Entry->Next->Name != NULL);
-        StrnCpy (Entry->Next->Name, VariableName, StrLen (VariableName));
+        StrCpyS (Entry->Next->Name, StrSize(VariableName)/sizeof(CHAR16), 
VariableName);
         Entry->Next->Volatile = Volatile;
       }
 

Modified: trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c    
2015-07-01 08:32:29 UTC (rev 17788)
+++ trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c    
2015-07-01 08:34:22 UTC (rev 17789)
@@ -1046,7 +1046,7 @@
       goto Done;
     }
     VariableName = (CHAR16 *) ((UINTN) Entry + sizeof (*Entry));
-    StrnCpy (VariableName, Name, StrLen (Name));
+    StrCpyS (VariableName, StrSize(Name)/sizeof(CHAR16), Name);
     CopyGuid (&Entry->Guid, Guid);
     CopyMem (&Entry->VariableProperty, VariableProperty, sizeof 
(*VariableProperty));
     InsertTailList (&mVarCheckVariableList, &Entry->Link);

Modified: trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c    
2015-07-01 08:32:29 UTC (rev 17788)
+++ trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c    
2015-07-01 08:34:22 UTC (rev 17789)
@@ -158,7 +158,7 @@
       CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);
       gVariableInfo->Name = AllocateZeroPool (StrSize (VariableName));
       ASSERT (gVariableInfo->Name != NULL);
-      StrnCpy (gVariableInfo->Name, VariableName, StrLen (VariableName));
+      StrCpyS (gVariableInfo->Name, StrSize(VariableName)/sizeof(CHAR16), 
VariableName);
       gVariableInfo->Volatile = Volatile;
     }
 
@@ -194,7 +194,7 @@
         CopyGuid (&Entry->Next->VendorGuid, VendorGuid);
         Entry->Next->Name = AllocateZeroPool (StrSize (VariableName));
         ASSERT (Entry->Next->Name != NULL);
-        StrnCpy (Entry->Next->Name, VariableName, StrLen (VariableName));
+        StrCpyS (Entry->Next->Name, StrSize(VariableName)/sizeof(CHAR16), 
VariableName);
         Entry->Next->Volatile = Volatile;
       }
 
@@ -2853,7 +2853,7 @@
   }
 
   Name = (CHAR16 *) ((UINTN) Entry + sizeof (*Entry));
-  StrnCpy   (Name, VariableName, StrLen (VariableName));
+  StrCpyS (Name, StrSize (VariableName)/sizeof(CHAR16), VariableName);
   CopyGuid (&Entry->Guid, VendorGuid);
   InsertTailList (&mLockedVariableList, &Entry->Link);
 


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to