MdeModulePkg/NetLib: Handle an invalid IPv6 address case

Handle an invalid IPv6 address in NetLibAsciiStrToIp6(),
like '2000:aaaa::1com'.

Cc: Zhang Lubo <lubo.zhang@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Zhang Lubo <lubo.zhang@intel.com>
This commit is contained in:
Jiaxin Wu
2016-11-25 14:14:23 +08:00
parent f17e28c791
commit 418373a1cd
2 changed files with 12 additions and 0 deletions

View File

@ -2832,6 +2832,17 @@ NetLibAsciiStrToIp6 (
TempStr = Ip6Str;
while ((*Ip6Str != '\0') && (*Ip6Str != ':')) {
if (Index != 14 && !NET_IS_HEX (*Ip6Str)) {
return EFI_INVALID_PARAMETER;
}
//
// Allow the IPv6 with prefix case, e.g. 2000:aaaa::10/24
//
if (Index == 14 && !NET_IS_HEX (*Ip6Str) && *Ip6Str != '/') {
return EFI_INVALID_PARAMETER;
}
Ip6Str++;
}