From: tye1 Date: Mon, 25 Jan 2010 03:29:59 +0000 (+0000) Subject: Update according to two review comments: X-Git-Tag: edk2-stable201903~16530 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=9b6f044a327dabb0a8cd3a38e8c0249fefbcc8af Update according to two review comments: 1. add some comments to clarify AsciiStrDecimalToUintn() can help filtering un-decimal characters. 2. change the condition judgment to “Index < 15” rather than (Index + 1 ) <16. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9803 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index 9ab7ab07c0..d89ac6483d 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -2458,6 +2458,10 @@ NetLibAsciiStrToIp4 ( } } + // + // Convert the string to IPv4 address. AsciiStrDecimalToUintn stops at the + // first character that is not a valid decimal character, '.' or '\0' here. + // NodeVal = AsciiStrDecimalToUintn (TempStr); if (NodeVal > 0xFF) { return EFI_INVALID_PARAMETER; @@ -2525,7 +2529,7 @@ NetLibAsciiStrToIp6 ( Short = FALSE; Update = FALSE; - for (Index = 0; (Index + 1) < 16; Index = (UINT8) (Index + 2)) { + for (Index = 0; Index < 15; Index = (UINT8) (Index + 2)) { TempStr = Ip6Str; while ((*Ip6Str != '\0') && (*Ip6Str != ':')) { @@ -2587,7 +2591,8 @@ NetLibAsciiStrToIp6 ( } // - // Convert the Str to IPv6 address. + // Convert the string to IPv6 address. AsciiStrHexToUintn stops at the first + // character that is not a valid hexadecimal character, ':' or '\0' here. // NodeVal = AsciiStrHexToUintn (TempStr); if ((NodeVal > 0xFFFF) || (Index > 14)) {