mirror of https://github.com/acidanthera/audk.git
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 <lubo.zhang@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17881 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
56b1927aa1
commit
206b5f51be
|
@ -3230,7 +3230,7 @@ NetLibIp6ToStr (
|
|||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
StrCpy (String, Buffer);
|
||||
StrCpyS (String, StringSize / sizeof (CHAR16), Buffer);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -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 @@ IScsiFormCallback (
|
|||
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;
|
||||
|
|
|
@ -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 @@ IScsiDhcpExtractRootPath (
|
|||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
AsciiStrCpy (ConfigNvData->TargetName, Field->Str);
|
||||
AsciiStrCpyS (ConfigNvData->TargetName, ISCSI_NAME_MAX_SIZE, Field->Str);
|
||||
|
||||
ON_EXIT:
|
||||
|
||||
|
|
|
@ -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 @@ IScsiExtScsiPassThruBuildDevicePath (
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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 @@ IScsiLunToUnicodeStr (
|
|||
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];
|
||||
|
|
|
@ -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 @@ Ip4DeviceExtractConfig (
|
|||
*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)) {
|
||||
|
|
|
@ -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 @@ Mtftp4SendRequest (
|
|||
|
||||
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 @@ Mtftp4SendError (
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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 @@ PxeBcCheckPacket (
|
|||
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 @@ PxeBcTftpGetFileSize (
|
|||
}
|
||||
|
||||
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 @@ PxeBcTftpGetFileSize (
|
|||
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 @@ PxeBcTftpReadFile (
|
|||
|
||||
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 @@ PxeBcTftpWriteFile (
|
|||
|
||||
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 @@ PxeBcTftpReadDirectory (
|
|||
|
||||
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++;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#define PXE_MTFTP_OPTION_MAXIMUM_INDEX 4
|
||||
|
||||
#define PXE_MTFTP_ERROR_STRING_LENGTH 127
|
||||
#define PXE_MTFTP_OPTBUF_MAXNUM_INDEX 128
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 @@ CvtNum (
|
|||
/**
|
||||
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 @@ UtoA10 (
|
|||
Number = Number / 10;
|
||||
} while (Number != 0);
|
||||
|
||||
AsciiStrCpy (Buffer, &TempStr[Index]);
|
||||
AsciiStrCpyS (Buffer, BufferSize, &TempStr[Index]);
|
||||
|
||||
return AsciiStrLen (Buffer);
|
||||
}
|
||||
|
|
|
@ -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 @@ CvtNum (
|
|||
/**
|
||||
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
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -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 @@ VlanUpdateForm (
|
|||
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 @@ InstallVlanConfigForm (
|
|||
}
|
||||
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),
|
||||
|
|
Loading…
Reference in New Issue