Revision: 17881
          http://sourceforge.net/p/edk2/code/17881
Author:   luobozhang
Date:     2015-07-08 06:35:37 +0000 (Wed, 08 Jul 2015)
Log Message:
-----------
MdeModulePkg: 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/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
    trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
    trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
    trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
    trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
    trunk/edk2/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c
    trunk/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
    trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c
    trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h
    trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
    trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h
    trunk/edk2/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c

Modified: trunk/edk2/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
===================================================================
--- trunk/edk2/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c       2015-07-08 
05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c       2015-07-08 
06:35:37 UTC (rev 17881)
@@ -3230,7 +3230,7 @@
     return EFI_BUFFER_TOO_SMALL;
   }
 
-  StrCpy (String, Buffer);
+  StrCpyS (String, StringSize / sizeof (CHAR16), Buffer);
 
   return EFI_SUCCESS;
 }

Modified: trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c    
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c    
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,7 +1,7 @@
 /** @file
   Helper functions for configuring or getting the parameters relating to iSCSI.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
@@ -778,7 +778,7 @@
       if (EFI_ERROR (Status)) {
         CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid 
iSCSI Name!", NULL);
       } else {
-        AsciiStrCpy (Private->Current->SessionConfigData.TargetName, 
IScsiName);
+        AsciiStrCpyS (Private->Current->SessionConfigData.TargetName, 
ISCSI_NAME_MAX_SIZE, IScsiName);
       }
 
       break;

Modified: trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c      
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c      
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,7 +1,7 @@
 /** @file
   iSCSI DHCP related configuration routines.
 
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
@@ -158,7 +158,7 @@
     goto ON_EXIT;
   }
 
-  AsciiStrCpy (ConfigNvData->TargetName, Field->Str);
+  AsciiStrCpyS (ConfigNvData->TargetName, ISCSI_NAME_MAX_SIZE, Field->Str);
 
 ON_EXIT:
 

Modified: 
trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c   
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c   
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,7 +1,7 @@
 /** @file
   The IScsi's EFI_EXT_SCSI_PASS_THRU_PROTOCOL driver.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
@@ -244,7 +244,7 @@
 
   CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64));
   Node->Iscsi.TargetPortalGroupTag = Session->TargetPortalGroupTag;
-  AsciiStrCpy ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), 
ConfigNvData->TargetName);
+  AsciiStrCpyS ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), AsciiStrLen 
(ConfigNvData->TargetName) + 1, ConfigNvData->TargetName);
 
   *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node;
 

Modified: trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c      
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c      
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,7 +1,7 @@
 /** @file
   Miscellaneous routines for iSCSI driver.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
@@ -204,7 +204,7 @@
   for (Index = 0; Index < 4; Index++) {
 
     if ((Lun[2 * Index] | Lun[2 * Index + 1]) == 0) {
-      StrCpy (TempStr, L"0-");
+      CopyMem(TempStr, L"0-", sizeof (L"0-"));
     } else {
       TempStr[0]  = (CHAR16) IScsiHexString[Lun[2 * Index] >> 4];
       TempStr[1]  = (CHAR16) IScsiHexString[Lun[2 * Index] & 0x0F];

Modified: trunk/edk2/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c        
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c        
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,7 +1,7 @@
 /** @file
   Helper functions for configuring or getting the parameters relating to Ip4.
 
-Copyright (c) 2009 - 2012, 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
@@ -487,10 +487,10 @@
     *Results = AllocateZeroPool (Size * sizeof (CHAR16));
     ASSERT (*Results != NULL);
     StrPointer  = *Results;
-    StrCpy (StrPointer, DeviceResult);
+    StrCpyS (StrPointer, Size, DeviceResult);
     StrPointer  = StrPointer + StrLen (StrPointer);
     *StrPointer = L'&';
-    StrCpy (StrPointer + 1, FormResult);
+    StrCpyS (StrPointer + 1, StrLen (FormResult) + 1, FormResult);
     FreePool (DeviceResult);
     FreePool (FormResult);
   } else if (HiiIsConfigHdrMatch (Request, &gEfiNicIp4ConfigVariableGuid, 
EFI_NIC_IP4_CONFIG_VARIABLE)) {

Modified: trunk/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c 
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c 
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,7 +1,7 @@
 /** @file
   Support routines for Mtftp.
   
-Copyright (c) 2006 - 2010, 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
@@ -319,17 +319,20 @@
 
   Packet->OpCode = HTONS (Instance->Operation);
   Cur            = Packet->Rrq.Filename;
-  Cur            = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) 
Token->Filename);
+  Cur            = (UINT8 *) AsciiStrCpyS ((CHAR8 *) Cur, Len - 2, (CHAR8 *) 
Token->Filename);
   Cur           += AsciiStrLen ((CHAR8 *) Token->Filename) + 1;
-  Cur            = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Mode);
+  Cur            = (UINT8 *) AsciiStrCpyS ((CHAR8 *) Cur, Len - 2 - 
(AsciiStrLen ((CHAR8 *) Token->Filename) + 1), (CHAR8 *) Mode);
   Cur           += AsciiStrLen ((CHAR8 *) Mode) + 1;
+  Len -= ((UINT32) AsciiStrLen ((CHAR8 *) Token->Filename) + (UINT32) 
AsciiStrLen ((CHAR8 *) Mode) + 4);
 
   for (Index = 0; Index < Token->OptionCount; ++Index) {
-    Cur  = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) 
Options[Index].OptionStr);
+    Cur  = (UINT8 *) AsciiStrCpyS ((CHAR8 *) Cur, Len, (CHAR8 *) 
Options[Index].OptionStr);
     Cur += AsciiStrLen ((CHAR8 *) Options[Index].OptionStr) + 1;
+    Len -= (AsciiStrLen ((CHAR8 *) Options[Index].OptionStr) + 1);
 
-    Cur  = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) 
Options[Index].ValueStr);
+    Cur  = (UINT8 *) AsciiStrCpyS ((CHAR8 *) Cur, Len, (CHAR8 *) 
Options[Index].ValueStr);
     Cur += AsciiStrLen ((CHAR8 *) (CHAR8 *) Options[Index].ValueStr) + 1;
+    Len -= (AsciiStrLen ((CHAR8 *) (CHAR8 *) Options[Index].ValueStr) + 1);
   }
 
   return Mtftp4SendPacket (Instance, Nbuf);
@@ -371,7 +374,7 @@
   TftpError->OpCode = HTONS (EFI_MTFTP4_OPCODE_ERROR);
   TftpError->Error.ErrorCode = HTONS (ErrCode);
 
-  AsciiStrCpy ((CHAR8 *) TftpError->Error.ErrorMessage, (CHAR8 *) ErrInfo);
+  AsciiStrCpyS ((CHAR8 *) TftpError->Error.ErrorMessage, Len, (CHAR8 *) 
ErrInfo);
 
   return Mtftp4SendPacket (Instance, Packet);
 }

Modified: trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c 
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c 
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,7 +1,7 @@
 /** @file
   PxeBc MTFTP functions.
   
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -60,7 +60,7 @@
   if (Packet->OpCode == EFI_MTFTP4_OPCODE_ERROR) {
     Private->Mode.TftpErrorReceived = TRUE;
     Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode;
-    AsciiStrnCpy (Private->Mode.TftpError.ErrorString, (CHAR8 *) 
Packet->Error.ErrorMessage, PXE_MTFTP_ERROR_STRING_LENGTH);
+    AsciiStrnCpyS (Private->Mode.TftpError.ErrorString, 
PXE_MTFTP_ERROR_STRING_LENGTH, (CHAR8 *) Packet->Error.ErrorMessage, 
PXE_MTFTP_ERROR_STRING_LENGTH - 1);
     Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = 
'\0';
   }
 
@@ -135,13 +135,13 @@
   }
 
   ReqOpt[0].OptionStr = (UINT8*)mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX];
-  UtoA10 (0, (CHAR8 *) OptBuf);
+  UtoA10 (0, (CHAR8 *) OptBuf, PXE_MTFTP_OPTBUF_MAXNUM_INDEX);
   ReqOpt[0].ValueStr = OptBuf;
 
   if (BlockSize != NULL) {
     ReqOpt[1].OptionStr = 
(UINT8*)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
     ReqOpt[1].ValueStr  = ReqOpt[0].ValueStr + AsciiStrLen ((CHAR8 *) 
ReqOpt[0].ValueStr) + 1;
-    UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[1].ValueStr);
+    UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[1].ValueStr, 
PXE_MTFTP_OPTBUF_MAXNUM_INDEX - (AsciiStrLen ((CHAR8 *) ReqOpt[0].ValueStr) + 
1));
     OptCnt++;
   }
 
@@ -160,10 +160,11 @@
     if (Status == EFI_TFTP_ERROR) {
       Private->Mode.TftpErrorReceived = TRUE;
       Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode;
-      AsciiStrnCpy (
-        Private->Mode.TftpError.ErrorString, 
-        (CHAR8 *) Packet->Error.ErrorMessage, 
-        PXE_MTFTP_ERROR_STRING_LENGTH
+      AsciiStrnCpyS (
+        Private->Mode.TftpError.ErrorString,
+        PXE_MTFTP_ERROR_STRING_LENGTH,
+        (CHAR8 *) Packet->Error.ErrorMessage,
+        PXE_MTFTP_ERROR_STRING_LENGTH - 1
         );
       Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = 
'\0';
     }
@@ -261,7 +262,7 @@
 
     ReqOpt[0].OptionStr = (UINT8*) 
mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
     ReqOpt[0].ValueStr  = OptBuf;
-    UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr);
+    UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr, 
PXE_MTFTP_OPTBUF_MAXNUM_INDEX);
     OptCnt++;
   }
 
@@ -344,7 +345,7 @@
 
     ReqOpt[0].OptionStr = (UINT8*) 
mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
     ReqOpt[0].ValueStr  = OptBuf;
-    UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr);
+    UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr, 
PXE_MTFTP_OPTBUF_MAXNUM_INDEX);
     OptCnt++;
   }
 
@@ -418,7 +419,7 @@
 
     ReqOpt[0].OptionStr = (UINT8*) 
mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
     ReqOpt[0].ValueStr  = OptBuf;
-    UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr);
+    UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr, 
PXE_MTFTP_OPTBUF_MAXNUM_INDEX);
     OptCnt++;
   }
 

Modified: trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h 
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h 
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,7 +1,7 @@
 /** @file
   Mtftp routines for PxeBc.
     
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -22,6 +22,7 @@
 #define PXE_MTFTP_OPTION_MAXIMUM_INDEX   4
 
 #define PXE_MTFTP_ERROR_STRING_LENGTH    127
+#define PXE_MTFTP_OPTBUF_MAXNUM_INDEX    128
 
 
 /**

Modified: trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c       
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c       
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,7 +1,7 @@
 /** @file
   Support routines for PxeBc.
 
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -140,16 +140,18 @@
 /**
   Convert unsigned int number to decimal number.
 
-  @param  Number   The unsigned int number will be converted.
-  @param  Buffer   Pointer to the buffer to store the decimal number after 
transform.
-
+  @param      Number         The unsigned int number will be converted.
+  @param      Buffer         Pointer to the buffer to store the decimal number 
after transform.
+  @param[in]  BufferSize     The maxsize of the buffer.
+  
   @return the length of the number after transform.
 
 **/
 UINTN
 UtoA10 (
   IN UINTN Number,
-  IN CHAR8 *Buffer
+  IN CHAR8 *Buffer,
+  IN UINTN BufferSize
   )
 {
   UINTN Index;
@@ -164,7 +166,7 @@
     Number          = Number / 10;
   } while (Number != 0);
 
-  AsciiStrCpy (Buffer, &TempStr[Index]);
+  AsciiStrCpyS (Buffer, BufferSize, &TempStr[Index]);
 
   return AsciiStrLen (Buffer);
 }

Modified: trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h       
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h       
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,6 +1,6 @@
 /** @file
   Support routines for PxeBc.
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -82,16 +82,19 @@
 /**
   Convert unsigned int number to decimal number.
 
-  @param  Number   The unsigned int number will be converted.
-  @param  Buffer   Pointer to the buffer to store the decimal number after 
transform.
-
+  @param      Number         The unsigned int number will be converted.
+  @param      Buffer         Pointer to the buffer to store the decimal number 
after transform.
+  @param[in]  BufferSize     The maxsize of the buffer.
+  
   @return the length of the number after transform.
 
 **/
 UINTN
 UtoA10 (
   IN UINTN Number,
-  IN CHAR8 *Buffer
+  IN CHAR8 *Buffer,
+  IN UINTN BufferSize
+  
   );
 
 

Modified: 
trunk/edk2/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c    
2015-07-08 05:54:44 UTC (rev 17880)
+++ trunk/edk2/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c    
2015-07-08 06:35:37 UTC (rev 17881)
@@ -1,7 +1,7 @@
 /** @file
   HII Config Access protocol implementation of VLAN configuration module.
 
-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
@@ -412,17 +412,17 @@
   for (Index = 0; Index < NumberOfVlan; Index++) {
     String = VlanStr;
 
-    StrCpy (String, L"  VLAN ID:");
+    StrCpyS (String, (sizeof (VlanStr) /sizeof (CHAR16)), L"  VLAN ID:");
     String += 10;
     //
     // Pad VlanId string up to 4 characters with space
     //
     DigitalCount = UnicodeValueToString (VlanIdStr, 0, VlanData[Index].VlanId, 
5);
     SetMem16 (String, (4 - DigitalCount) * sizeof (CHAR16), L' ');
-    StrCpy (String + 4 - DigitalCount, VlanIdStr);
+    StrCpyS (String + 4 - DigitalCount, (sizeof (VlanStr) /sizeof (CHAR16)) - 
10 - (4 - DigitalCount), VlanIdStr);
     String += 4;
 
-    StrCpy (String, L", Priority:");
+    StrCpyS (String,  (sizeof (VlanStr) /sizeof (CHAR16)) - 10 - (4 - 
DigitalCount) - 4, L", Priority:");
     String += 11;
     String += UnicodeValueToString (String, 0, VlanData[Index].Priority, 4);
     *String = 0;
@@ -559,9 +559,9 @@
   }
   PrivateData->MacString = MacString;
 
-  StrCpy (Str, L"VLAN Configuration (MAC:");
-  StrnCat (Str, MacString, sizeof (EFI_MAC_ADDRESS) * 2);
-  StrCat (Str, L")");
+  StrCpyS (Str, sizeof (Str) / sizeof (CHAR16), L"VLAN Configuration (MAC:");
+  StrCatS (Str, sizeof (Str) / sizeof (CHAR16), MacString);
+  StrCatS (Str, sizeof (Str) / sizeof (CHAR16), L")");
   HiiSetString (
     HiiHandle,
     STRING_TOKEN (STR_VLAN_FORM_SET_TITLE_HELP),


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