From: Jiaxin Wu Date: Fri, 18 Nov 2016 07:38:32 +0000 (+0800) Subject: MdeModulePkg/DxeNetLib: Allow the IPv4/prefix case when AsciiStrToIp4 X-Git-Tag: edk2-stable201903~5103 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=67bb14259baaf2237b81bcbf2568517b3310b294 MdeModulePkg/DxeNetLib: Allow the IPv4/prefix case when AsciiStrToIp4 This patch is used to allow the IPv4 with prefix case. Cc: Fu Siyuan Cc: Ye Ting Cc: Zhang Lubo Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu Reviewed-by: Fu Siyuan --- diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index 04d8345a6d..0804052fac 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -2724,9 +2724,17 @@ NetLibAsciiStrToIp4 ( TempStr = Ip4Str; while ((*Ip4Str != '\0') && (*Ip4Str != '.')) { - if (!NET_IS_DIGIT (*Ip4Str)) { + if (Index != 3 && !NET_IS_DIGIT (*Ip4Str)) { return EFI_INVALID_PARAMETER; } + + // + // Allow the IPv4 with prefix case, e.g. 192.168.10.10/24 + // + if (Index == 3 && !NET_IS_DIGIT (*Ip4Str) && *Ip4Str != '/') { + return EFI_INVALID_PARAMETER; + } + Ip4Str++; }