public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Guoheyi <guoheyi@huawei.com>
To: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: Feng Tian <feng.tian@intel.com>, Star Zeng <star.zeng@intel.com>,
	"Siyuan Fu" <siyuan.fu@intel.com>,
	Jiaxin Wu <jiaxin.wu@intel.com>
Subject: [DxeNetLib] Why do we restrict each field to have the same leading zero format?
Date: Wed, 5 Apr 2017 10:55:59 +0000	[thread overview]
Message-ID: <B328F08581D714418202ABF306D3781C3AC11473@DGGEMA505-MBS.china.huawei.com> (raw)

Hi folks,

We are using NetLibAsciiStrToIp6 function in DxeNetLib.c of MdeModulePkg to convert string to IPv6 address. We found this function will return invalid parameter with below input:
2001:3456:789a:0000:f012:2:2003:2005

We trace the code and believe it is handled by the branch in line 2955:

      if ((Cnt != 0) && (Cnt < 4) && LeadZero) {
        return EFI_INVALID_PARAMETER;
      }

I think the reason is that we have field 3 of "0000" which has leading zero and causes LeadZero flag to be true, and it requires all the following fields to have the same leading zero format, while field 5 of "2" is not.

I checked RFC 4291 and only found below text; I didn't find any restriction that requires each field to have the same leading zero format.

   1. The preferred form is x:x:x:x:x:x:x:x, where the 'x's are one to
      four hexadecimal digits of the eight 16-bit pieces of the address.
      Examples:

         ABCD:EF01:2345:6789:ABCD:EF01:2345:6789

         2001:DB8:0:0:8:800:200C:417A

      Note that it is not necessary to write the leading zeros in an
      individual field, but there must be at least one numeral in every
      field (except for the case described in 2.).

Could you help to confirm whether it is a bug or there is some special reason for this?

Thanks and regards,

Gary (Heyi Guo)


             reply	other threads:[~2017-04-05 10:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-05 10:55 Guoheyi [this message]
2017-04-06  5:30 ` [DxeNetLib] Why do we restrict each field to have the same leading zero format? Wu, Jiaxin
2017-04-06  7:35   ` 答复: " Guoheyi

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=B328F08581D714418202ABF306D3781C3AC11473@DGGEMA505-MBS.china.huawei.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