summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library/DxeNetLib
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2017-01-18 10:31:02 +0800
committerHao Wu <hao.a.wu@intel.com>2017-03-02 09:58:11 +0800
commit9f4048f7f8cd4b6bd5eee0f0c4bfd4eb6926a536 (patch)
tree0b3a079754cfcbf7c867e13d4eaefdc5545dcb23 /MdeModulePkg/Library/DxeNetLib
parent0438f5e287fa40c7aa143c3a151c5e5c743411b3 (diff)
downloadedk2-platforms-9f4048f7f8cd4b6bd5eee0f0c4bfd4eb6926a536.tar.xz
MdeModulePkg: Replace [Ascii|Unicode]ValueToString
It is the follow up of commits 51f0ceb..9e32e97 to replace AsciiValueToString/UnicodeValueToString with AsciiValueToStringS/UnicodeValueToStringS. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
Diffstat (limited to 'MdeModulePkg/Library/DxeNetLib')
-rw-r--r--MdeModulePkg/Library/DxeNetLib/DxeNetLib.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index 37b89f5ca4..6066526abe 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -2225,6 +2225,7 @@ NetLibGetMacString (
UINT16 VlanId;
CHAR16 *String;
UINTN Index;
+ UINTN BufferSize;
ASSERT (MacString != NULL);
@@ -2241,7 +2242,8 @@ NetLibGetMacString (
// If VLAN is configured, it will need extra 5 characters like "\0005".
// Plus one unicode character for the null-terminator.
//
- String = AllocateZeroPool ((2 * HwAddressSize + 5 + 1) * sizeof (CHAR16));
+ BufferSize = (2 * HwAddressSize + 5 + 1) * sizeof (CHAR16);
+ String = AllocateZeroPool (BufferSize);
if (String == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -2252,7 +2254,14 @@ NetLibGetMacString (
//
HwAddress = &MacAddress.Addr[0];
for (Index = 0; Index < HwAddressSize; Index++) {
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
+ UnicodeValueToStringS (
+ String,
+ BufferSize - ((UINTN)String - (UINTN)*MacString),
+ PREFIX_ZERO | RADIX_HEX,
+ *(HwAddress++),
+ 2
+ );
+ String += StrnLenS (String, (BufferSize - ((UINTN)String - (UINTN)*MacString)) / sizeof (CHAR16));
}
//
@@ -2261,7 +2270,14 @@ NetLibGetMacString (
VlanId = NetLibGetVlanId (ServiceHandle);
if (VlanId != 0) {
*String++ = L'\\';
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, VlanId, 4);
+ UnicodeValueToStringS (
+ String,
+ BufferSize - ((UINTN)String - (UINTN)*MacString),
+ PREFIX_ZERO | RADIX_HEX,
+ VlanId,
+ 4
+ );
+ String += StrnLenS (String, (BufferSize - ((UINTN)String - (UINTN)*MacString)) / sizeof (CHAR16));
}
//