From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1DBB39418FD for ; Wed, 13 Dec 2023 13:15:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ssTHVc1bByZ/wbC6W869jF78pvOYJ+LWmM0DSoHSiLU=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1702473320; v=1; b=YX4q7ECcMEGoiybteUOBfPuNaKkz49Fwu7spm2+iflPImhccLU9f0EwQVoUEvMqtOAjtCzNG fUCDtEP8BJHCRXY0J8aEO5X0HDRI0iwstPSQzoIZgFj1Qs0qpvLnknKmg6Q5UIOaG2mo45TiWqO iKKoqJrY42lRLiBp9BTCM8T0= X-Received: by 127.0.0.2 with SMTP id dDyEYY7687511xqqUrGmR6sh; Wed, 13 Dec 2023 05:15:20 -0800 X-Received: from mail-vk1-f178.google.com (mail-vk1-f178.google.com [209.85.221.178]) by mx.groups.io with SMTP id smtpd.web11.35330.1702473320002656374 for ; Wed, 13 Dec 2023 05:15:20 -0800 X-Received: by mail-vk1-f178.google.com with SMTP id 71dfb90a1353d-4b302c8213cso1736010e0c.3 for ; Wed, 13 Dec 2023 05:15:19 -0800 (PST) X-Gm-Message-State: X9hNfdQo3n6HnEOZHO88iS81x7686176AA= X-Google-Smtp-Source: AGHT+IFj0La8YhXdlb8f9ULQhP59J6QJSKKIXRPruxoyULAFkvKg+GSo+xrEf5Q4BwArjUJEd9dFTgiC7P6QNU6o/yU= X-Received: by 2002:a05:6122:4b1c:b0:4b2:c554:fbb4 with SMTP id fc28-20020a0561224b1c00b004b2c554fbb4mr6734975vkb.22.1702473318572; Wed, 13 Dec 2023 05:15:18 -0800 (PST) MIME-Version: 1.0 References: <20231207132419.6107-1-mike.maslenkin@gmail.com> In-Reply-To: <20231207132419.6107-1-mike.maslenkin@gmail.com> From: "Pedro Falcato" Date: Wed, 13 Dec 2023 13:15:07 +0000 Message-ID: Subject: Re: [edk2-devel] [RFC PATCH] RedfishPkg: RedfishDiscoverDxe: add [] brackets to URI for IPv6 addresses To: devel@edk2.groups.io, mike.maslenkin@gmail.com Cc: Abner Chang , Nickle Wang , Igor Kulchytskyy Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pedro.falcato@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=YX4q7ECc; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Thu, Dec 7, 2023 at 1:24=E2=80=AFPM Mike Maslenkin wrote: > > URI is generated based on the RedfishLocation containing an ASCII string > representing the IP address. So, in the case of IPv4 the canonical > representation of an IPv4 address was inserted into the resulting Unicode > string i.e: "http{,s}://X.X.X.X/". > > In the case of IPv6, to access resources, the IP address must be specifie= d > in brackets, i.e. the resulting string should look like: > "http{,s}://[X::X:X:X:X]/". > > Cc: Abner Chang > Cc: Nickle Wang > Cc: Igor Kulchytskyy > Signed-off-by: Mike Maslenkin > --- > .../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 20 ++++++++++++++++--- > 1 file changed, 17 insertions(+), 3 deletions(-) > > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/Redfish= Pkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > index 28ba2d3a9fca..49c96bd28b27 100644 > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > @@ -863,9 +863,23 @@ AddAndSignalNewRedfishService ( > } > > if (RedfishLocation !=3D NULL) { > - DiscoveredInstance->Information.Location =3D (CHAR16 *)AllocatePoo= l (AsciiStrSize ((const CHAR8 *)RedfishLocation) * sizeof (CHAR16)); > - AsciiStrToUnicodeStrS ((const CHAR8 *)RedfishLocation, DiscoveredI= nstance->Information.Location, AsciiStrSize ((const CHAR8 *)RedfishLocation= ) * sizeof (CHAR16)); > - DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", Di= scoveredInstance->Information.Location)); > + UINTN AllocSize; > + CONST CHAR8 *IpAddress; > + > + IpAddress =3D (CONST CHAR8 *)RedfishLocation; > + AllocSize =3D AsciiStrSize (IpAddress) * sizeof (CHAR16); > + > + if (CheckIsIpVersion6 (NetworkInterface)) { > + AllocSize +=3D 2 * sizeof (CHAR16); // take into account '[' and= ']' > + > + DiscoveredInstance->Information.Location =3D (CHAR16 *)AllocateP= ool (AllocSize); You don't check for NULL. > + UnicodeSPrintAsciiFormat (DiscoveredInstance->Information.Locati= on, AllocSize, "[%a]", IpAddress); > + } else { > + DiscoveredInstance->Information.Location =3D (CHAR16 *)AllocateP= ool (AllocSize); You don't check for NULL. Heck, why does no one check for NULL in this whole function (AddAndSignalNewRedfishService)? --=20 Pedro -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112472): https://edk2.groups.io/g/devel/message/112472 Mute This Topic: https://groups.io/mt/103033764/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-