Revision: 17882
          http://sourceforge.net/p/edk2/code/17882
Author:   luobozhang
Date:     2015-07-08 06:59:50 +0000 (Wed, 08 Jul 2015)
Log Message:
-----------
SecurityPkg:Replace unsafe string functions.

Replace unsafe string functions with new added safe string functions.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <[email protected]>
Reviewed-by: Fu Siyuan <[email protected]>
Reviewed-by: Qiu Shumin <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>

Modified Paths:
--------------
    
trunk/edk2/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
    
trunk/edk2/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.c
    
trunk/edk2/SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileModify.c
    trunk/edk2/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
    
trunk/edk2/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
    
trunk/edk2/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigMisc.c

Modified: 
trunk/edk2/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
===================================================================
--- 
trunk/edk2/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
        2015-07-08 06:35:37 UTC (rev 17881)
+++ 
trunk/edk2/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
        2015-07-08 06:59:50 UTC (rev 17882)
@@ -544,7 +544,7 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -556,11 +556,11 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
       
@@ -572,7 +572,7 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -584,11 +584,11 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1); 
       break;
 
@@ -601,12 +601,12 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_CLEAR));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
-      StrnCat (ConfirmText, L" \n\n", (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n\n", (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);      
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -618,11 +618,11 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_ON));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -634,15 +634,15 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_OFF));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -654,7 +654,7 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -666,7 +666,7 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -678,11 +678,11 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_ON));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -694,15 +694,15 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_OFF));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -715,11 +715,11 @@
       FreePool (TmpStr1);
       
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_MAINTAIN));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -740,19 +740,19 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_ON));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_CLEAR));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_CLEAR_CONT));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -764,11 +764,11 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NO_PPI_INFO));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -781,20 +781,20 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_CLEAR));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_CLEAR));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
-      StrnCat (ConfirmText, L" \n\n", (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n\n", (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1); 
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NO_PPI_INFO));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -807,15 +807,15 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_MAINTAIN));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NO_PPI_INFO));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -828,12 +828,12 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_CLEAR));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
-      StrnCat (ConfirmText, L" \n\n", (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n\n", (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -846,19 +846,19 @@
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_ON));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_CLEAR));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_CLEAR_CONT));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -877,7 +877,7 @@
 
   DstStr[80] = L'\0';
   for (Index = 0; Index < StrLen (ConfirmText); Index += 80) {
-    StrnCpy(DstStr, ConfirmText + Index, 80);    
+    StrnCpyS(DstStr, sizeof (DstStr) / sizeof (CHAR16), ConfirmText + Index, 
sizeof (DstStr) / sizeof (CHAR16) - 1);    
     Print (DstStr);    
   }
   

Modified: 
trunk/edk2/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.c
===================================================================
--- 
trunk/edk2/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.c
      2015-07-08 06:35:37 UTC (rev 17881)
+++ 
trunk/edk2/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.c
      2015-07-08 06:59:50 UTC (rev 17882)
@@ -261,12 +261,12 @@
       FreePool (TmpStr1);
 
       TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_CLEAR));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
-      StrnCat (ConfirmText, L" \n\n", (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n\n", (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);      
 
       TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_CAUTION_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -279,20 +279,20 @@
       FreePool (TmpStr1);
 
       TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_NOTE_CLEAR));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_WARNING_CLEAR));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
-      StrnCat (ConfirmText, L" \n\n", (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n\n", (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1); 
 
       TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_CAUTION_KEY));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
 
       TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN 
(TPM_NO_PPI_INFO));
-      StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen 
(ConfirmText) - 1);
+      StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / 
sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
       FreePool (TmpStr1);
       break;
 
@@ -311,7 +311,7 @@
 
   DstStr[80] = L'\0';
   for (Index = 0; Index < StrLen (ConfirmText); Index += 80) {
-    StrnCpy(DstStr, ConfirmText + Index, 80);    
+    StrnCpyS(DstStr, sizeof (DstStr) / sizeof (CHAR16), ConfirmText + Index, 
sizeof (DstStr) / sizeof (CHAR16) - 1);    
     Print (DstStr);    
   }
   

Modified: 
trunk/edk2/SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileModify.c
===================================================================
--- 
trunk/edk2/SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileModify.c
 2015-07-08 06:35:37 UTC (rev 17881)
+++ 
trunk/edk2/SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileModify.c
 2015-07-08 06:59:50 UTC (rev 17882)
@@ -1,7 +1,7 @@
 /** @file
   The functions to modify a user profile.
     
-Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 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 
@@ -345,11 +345,11 @@
   ASSERT (TmpStr != NULL);
 
   if (*Source1 == NULL) {
-    StrCpy (TmpStr, Source2);;
+    StrCpyS (TmpStr, StrLength / sizeof (CHAR16), Source2);
   } else {
-    StrCpy (TmpStr, *Source1);
+    StrCpyS (TmpStr, StrLength / sizeof (CHAR16), *Source1);
     FreePool (*Source1);
-    StrCat (TmpStr, Source2);
+    StrCatS (TmpStr, StrLength / sizeof (CHAR16),Source2);
   }
 
   *Source1 = TmpStr;

Modified: 
trunk/edk2/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
===================================================================
--- trunk/edk2/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c  
2015-07-08 06:35:37 UTC (rev 17881)
+++ trunk/edk2/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c  
2015-07-08 06:59:50 UTC (rev 17882)
@@ -1,7 +1,7 @@
 /** @file
   The implementation of Extended SAL variable services.
 
-Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 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 
@@ -736,7 +736,7 @@
       CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);
       gVariableInfo->Name = AllocatePool (StrSize (VariableName));
       ASSERT (gVariableInfo->Name != NULL);
-      StrCpy (gVariableInfo->Name, VariableName);
+      StrCpyS (gVariableInfo->Name, StrSize (VariableName) / sizeof (CHAR16), 
VariableName);
       gVariableInfo->Volatile = Volatile;
 
       gBS->InstallConfigurationTable (&gEfiAuthenticatedVariableGuid, 
gVariableInfo);
@@ -778,7 +778,7 @@
         CopyGuid (&Entry->Next->VendorGuid, VendorGuid);
         Entry->Next->Name = AllocatePool (StrSize (VariableName));
         ASSERT (Entry->Next->Name != NULL);
-        StrCpy (Entry->Next->Name, VariableName);
+        StrCpyS (Entry->Next->Name, StrSize (VariableName) / sizeof (CHAR16), 
VariableName);
         Entry->Next->Volatile = Volatile;
       }
 

Modified: 
trunk/edk2/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
===================================================================
--- 
trunk/edk2/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
     2015-07-08 06:35:37 UTC (rev 17881)
+++ 
trunk/edk2/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
     2015-07-08 06:59:50 UTC (rev 17882)
@@ -1,7 +1,7 @@
 /** @file
   Internal file explorer functions for SecureBoot configuration module.
 
-Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2012 - 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
@@ -139,6 +139,7 @@
 {
   UINTN   Size1;
   UINTN   Size2;
+  UINTN   BufferSize;
   CHAR16  *Str;
   CHAR16  *TmpStr;
   CHAR16  *Ptr;
@@ -146,18 +147,20 @@
 
   Size1 = StrSize (Str1);
   Size2 = StrSize (Str2);
-  Str   = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));
+  BufferSize = Size1 + Size2 + sizeof (CHAR16);
+  Str   = AllocateZeroPool (BufferSize);
   ASSERT (Str != NULL);
 
-  TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));
+  TmpStr = AllocateZeroPool (BufferSize);
   ASSERT (TmpStr != NULL);
 
-  StrCat (Str, Str1);
+  StrCatS (Str, BufferSize / sizeof (CHAR16), Str1);
+
   if (!((*Str == '\\') && (*(Str + 1) == 0))) {
-    StrCat (Str, L"\\");
+    StrCatS (Str, BufferSize / sizeof (CHAR16), L"\\");
   }
 
-  StrCat (Str, Str2);
+  StrCatS (Str, BufferSize / sizeof (CHAR16), Str2);
 
   Ptr       = Str;
   LastSlash = Str;
@@ -170,11 +173,11 @@
       //
 
       //
-      // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of 
two strings
+      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of 
two strings
       // that overlap.
       //
-      StrCpy (TmpStr, Ptr + 3);
-      StrCpy (LastSlash, TmpStr);
+      StrCpyS (TmpStr, BufferSize / sizeof (CHAR16), Ptr + 3);
+      StrCpyS (LastSlash, BufferSize / sizeof (CHAR16), TmpStr);
       Ptr = LastSlash;
     } else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {
       //
@@ -182,11 +185,11 @@
       //
 
       //
-      // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of 
two strings
+      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of 
two strings
       // that overlap.
       //
-      StrCpy (TmpStr, Ptr + 2);
-      StrCpy (Ptr, TmpStr);
+      StrCpyS (TmpStr, BufferSize / sizeof (CHAR16), Ptr + 2);
+      StrCpyS (Ptr, BufferSize / sizeof (CHAR16), TmpStr);
       Ptr = LastSlash;
     } else if (*Ptr == '\\') {
       LastSlash = Ptr;

Modified: 
trunk/edk2/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigMisc.c
===================================================================
--- 
trunk/edk2/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigMisc.c
     2015-07-08 06:35:37 UTC (rev 17881)
+++ 
trunk/edk2/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigMisc.c
     2015-07-08 06:59:50 UTC (rev 17882)
@@ -1,7 +1,7 @@
 /** @file
   Helper functions for SecureBoot configuration module.
 
-Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 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
@@ -184,7 +184,7 @@
     return EFI_OUT_OF_RESOURCES;
   }
 
-  StrCpy (Buffer, Str);
+  StrCpyS (Buffer, (StrLen + 1), Str);
 
   //
   // Data1


------------------------------------------------------------------------------
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