public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Fu, Siyuan" <siyuan.fu@intel.com>
To: "Wu, Jiaxin" <jiaxin.wu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Zhang, Lubo" <lubo.zhang@intel.com>, "Ye, Ting" <ting.ye@intel.com>
Subject: Re: [Patch] MdeModulePkg/NetLib: Handle an invalid IPv6 address case
Date: Fri, 25 Nov 2016 06:43:33 +0000	[thread overview]
Message-ID: <B1FF2E9001CE9041BD10B825821D5BC58A855530@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1480054550-201956-1-git-send-email-jiaxin.wu@intel.com>

Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>



> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Friday, November 25, 2016 2:16 PM
> To: edk2-devel@lists.01.org
> Cc: Zhang, Lubo <lubo.zhang@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>;
> Ye, Ting <ting.ye@intel.com>
> Subject: [Patch] 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>
> ---
>  MdeModulePkg/Include/Library/NetLib.h      |  1 +
>  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 11 +++++++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/MdeModulePkg/Include/Library/NetLib.h
> b/MdeModulePkg/Include/Library/NetLib.h
> index 26709af..09ead09 100644
> --- a/MdeModulePkg/Include/Library/NetLib.h
> +++ b/MdeModulePkg/Include/Library/NetLib.h
> @@ -521,10 +521,11 @@ extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM];
> 
> 
>  extern EFI_IPv4_ADDRESS  mZeroIp4Addr;
> 
>  #define NET_IS_DIGIT(Ch)            (('0' <= (Ch)) && ((Ch) <= '9'))
> +#define NET_IS_HEX(Ch)              ((('0' <= (Ch)) && ((Ch) <= '9')) ||
> (('A' <= (Ch)) && ((Ch) <= 'F')) || (('a' <= (Ch)) && ((Ch) <= 'f')))
>  #define NET_ROUNDUP(size, unit)     (((size) + (unit) - 1) & (~((unit) -
> 1)))
>  #define NET_IS_LOWER_CASE_CHAR(Ch)  (('a' <= (Ch)) && ((Ch) <= 'z'))
>  #define NET_IS_UPPER_CASE_CHAR(Ch)  (('A' <= (Ch)) && ((Ch) <= 'Z'))
> 
>  #define TICKS_PER_MS            10000U
> diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> index 0804052..0a7117c 100644
> --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> @@ -2830,10 +2830,21 @@ NetLibAsciiStrToIp6 (
> 
>    for (Index = 0; Index < 15; Index = (UINT8) (Index + 2)) {
>      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++;
>      }
> 
>      if ((*Ip6Str == '\0') && (Index != 14)) {
>        return EFI_INVALID_PARAMETER;
> --
> 1.9.5.msysgit.1



  reply	other threads:[~2016-11-25  6:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25  6:15 [Patch] MdeModulePkg/NetLib: Handle an invalid IPv6 address case Jiaxin Wu
2016-11-25  6:43 ` Fu, Siyuan [this message]
2016-11-25  7:20 ` Ye, Ting
2016-11-25  8:13 ` Zhang, Lubo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B1FF2E9001CE9041BD10B825821D5BC58A855530@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox