From nobody Mon May 6 13:29:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 153317285323968.33487967995518; Wed, 1 Aug 2018 18:20:53 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1E311210D5146; Wed, 1 Aug 2018 18:20:52 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E9149210D512B for ; Wed, 1 Aug 2018 18:20:50 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Aug 2018 18:20:50 -0700 Received: from jiaxinwu-mobl.ccr.corp.intel.com ([10.239.192.149]) by fmsmga004.fm.intel.com with ESMTP; 01 Aug 2018 18:20:47 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,434,1526367600"; d="scan'208";a="76567936" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Thu, 2 Aug 2018 09:20:43 +0800 Message-Id: <20180802012043.15608-1-Jiaxin.wu@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 Subject: [edk2] [PATCH v2] NetworkPkg/HttpDxe: Strip square brackets in IPv6 expressed HostName. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Fu Siyuan , Wu Jiaxin , Laszlo Ersek MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" *v2: Optimize the patch by calculating AsciiStrSize() only once. In URI, the colon (:) is used to terminate the HostName path before a port number. However, if HostName is expressed as IPv6 format, colon characters in IPv6 addresses will conflict with the colon before port number. To alleviate this conflict in URI, the IPv6 expressed HostName are enclosed in square brackets ([]). To record the real IPv6 HostName, square brackets should be stripped. Cc: Ye Ting Cc: Fu Siyuan Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Fu Siyuan Reviewed-by: Laszlo Ersek --- NetworkPkg/HttpDxe/HttpImpl.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index 17deceb395..de48243982 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -403,14 +403,26 @@ EfiHttpRequest ( Status =3D HttpParseUrl (Url, (UINT32) AsciiStrLen (Url), FALSE, &UrlP= arser); if (EFI_ERROR (Status)) { goto Error1; } =20 - HostName =3D NULL; - Status =3D HttpUrlGetHostName (Url, UrlParser, &HostName); + Status =3D HttpUrlGetHostName (Url, UrlParser, &HostName); if (EFI_ERROR (Status)) { - goto Error1; + goto Error1; + } + + if (HttpInstance->LocalAddressIsIPv6) { + HostNameSize =3D AsciiStrSize (HostName); + + if (HostNameSize > 2 && HostName[0] =3D=3D '[' && HostName[HostNameS= ize - 2] =3D=3D ']') { + // + // HostName format is expressed as IPv6, so, remove '[' and ']'. + // + HostNameSize -=3D 2; + CopyMem (HostName, HostName + 1, HostNameSize - 1); + HostName[HostNameSize - 1] =3D '\0'; + } } =20 Status =3D HttpUrlGetPort (Url, UrlParser, &RemotePort); if (EFI_ERROR (Status)) { if (HttpInstance->UseHttps) { --=20 2.17.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel