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 3F1559416BF for ; Mon, 26 Feb 2024 11:02:09 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=c/2WABfFoxx7OjQmsUnofhvcqqNSy6Unb0Awo9mXCLs=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1708945327; v=1; b=qkAgZbiQEkfIkVZdoxpD/3qHaEeuuFWFwxA4jZlDYy0L2rHn+pcUzW20H15o6wYiUTykJIW0 PN0FnwzUKNx/RyJUsWPRI0BGnvm0w7Xt8nwh64A4csvyQkGuZWh4r2NUYRlu+8bNpciaewnc9c5 B39VOcdlEbqemMbLDfuyXeDw= X-Received: by 127.0.0.2 with SMTP id VdkpYY7687511x6VVHCUd12Z; Mon, 26 Feb 2024 03:02:07 -0800 X-Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by mx.groups.io with SMTP id smtpd.web11.17762.1708945326410369561 for ; Mon, 26 Feb 2024 03:02:07 -0800 X-Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 106233FA63 for ; Mon, 26 Feb 2024 11:02:04 +0000 (UTC) X-Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-33d7e755f52so1431043f8f.1 for ; Mon, 26 Feb 2024 03:02:04 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVKA0kOWMo3pORcJ1zpKOlpkNRRH65nuZXwSKb3/9V1D+rh77HHhWgoHJRpBESSNBtz/EKKi076sPhNcYsEw79zPLVkBw== X-Gm-Message-State: Dd0FrV3l3SL9CEHUJE7XzQrVx7686176AA= X-Received: by 2002:a5d:5445:0:b0:33d:8751:2288 with SMTP id w5-20020a5d5445000000b0033d87512288mr4310940wrv.13.1708945323554; Mon, 26 Feb 2024 03:02:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpFOgEffL1Yca0PqmheQw02z+xBSa9T6Ck/m5VKFrci7l9c4ji8AcXeXI2G1rYHAB36TmWGw== X-Received: by 2002:a5d:5445:0:b0:33d:8751:2288 with SMTP id w5-20020a5d5445000000b0033d87512288mr4310930wrv.13.1708945323196; Mon, 26 Feb 2024 03:02:03 -0800 (PST) X-Received: from [192.168.30.47] (dynamic-176-001-242-221.176.1.pool.telefonica.de. [176.1.242.221]) by smtp.gmail.com with ESMTPSA id bq7-20020a5d5a07000000b0033cddadde6esm8067985wrb.80.2024.02.26.03.02.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 03:02:02 -0800 (PST) Message-ID: Date: Mon, 26 Feb 2024 12:02:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v1] SctPkg: Fixed a pinter error in DevicePathFromTextBBTestCoverage.c To: Chao Li Cc: G Edhaya Chandran , Barton Gao , Carolyn Gjertsen , edk2-devel References: <20240226101752.247067-1-lichao@...> From: "Heinrich Schuchardt" In-Reply-To: <20240226101752.247067-1-lichao@...> 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,heinrich.schuchardt@canonical.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed 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=qkAgZbiQ; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=canonical.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 26.02.24 11:17, Chao Li wrote: > DevicePathFromTextBBTextCoverage.c function CreateDNSDeviceNode has a > bug, code: >=20 > SctStrToIPv4Addr (&IpStr1, (EFI_IPv4_ADDRESS *)(DNS + sizeof (DNS_DEVICE_= PATH))); >=20 > DNS is a pointer, which is increased by a structure size and converted > to EFI_IPv4_ADDRESS*, which will point to an unknown address. So fix it. Hello Chao, thanks for diving into this. Please, add Fixes: 847e0363e846 ("SctPkg: Fix the UefiSct=20 -Wincompatible-pointer-types warnings") >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4712 >=20 > Cc: G Edhaya Chandran > Cc: Barton Gao > Cc: Carolyn Gjertsen > Signed-off-by: Chao Li > --- > .../BlackBoxTest/DevicePathFromTextBBTestCoverage.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) >=20 > diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathFromTex= t/BlackBoxTest/DevicePathFromTextBBTestCoverage.c b/uefi-sct/SctPkg/TestCas= e/UEFI/EFI/Protocol/DevicePathFromText/BlackBoxTest/DevicePathFromTextBBTes= tCoverage.c > index c96ee246..bd11c25a 100644 > --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathFromText/Black= BoxTest/DevicePathFromTextBBTestCoverage.c > +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathFromText/Black= BoxTest/DevicePathFromTextBBTestCoverage.c > @@ -1734,13 +1734,13 @@ CreateDNSDeviceNode ( > } >=20 > if (DNS->IsIPv6 =3D=3D 0) { > - SctStrToIPv4Addr (&IpStr1, (EFI_IPv4_ADDRESS *)(DNS + sizeof (DNS_DE= VICE_PATH))); > - SctStrToIPv4Addr (&IpStr2, (EFI_IPv4_ADDRESS *)(DNS + sizeof (DNS_DE= VICE_PATH) + sizeof(EFI_IP_ADDRESS))); > + SctStrToIPv4Addr (&IpStr1, (EFI_IPv4_ADDRESS *)((UINT8 *)DNS + sizeo= f (DNS_DEVICE_PATH))); > + SctStrToIPv4Addr (&IpStr2, (EFI_IPv4_ADDRESS *)((UINT8 *)DNS + sizeo= f (DNS_DEVICE_PATH) + sizeof(EFI_IP_ADDRESS))); > } >=20 > if (DNS->IsIPv6 =3D=3D 1) { > - SctStrToIPv6Addr (&IpStr1, (EFI_IPv6_ADDRESS *)(DNS + sizeof (DNS_DE= VICE_PATH))); > - SctStrToIPv6Addr (&IpStr2, (EFI_IPv6_ADDRESS *)(DNS + sizeof (DNS_DE= VICE_PATH) + sizeof(EFI_IP_ADDRESS))); > + SctStrToIPv6Addr (&IpStr1, (EFI_IPv6_ADDRESS *)((UINT8 *)DNS + sizeo= f (DNS_DEVICE_PATH))); > + SctStrToIPv6Addr (&IpStr2, (EFI_IPv6_ADDRESS *)((UINT8 *)DNS + sizeo= f (DNS_DEVICE_PATH) + sizeof(EFI_IP_ADDRESS))); The change looks correct. I would prefer using the fields of the DNS_DEVICE_PATH typedef from=20 MdePkg/Include/Protocol/DevicePath.h to avoid the conversions: > + SctStrToIPv4Addr (&IpStr1, &DNS->DnsServerIp[0].v4) > + SctStrToIPv4Addr (&IpStr2, &DNS->DnsServerIp[1].v4) > + SctStrToIPv6Addr (&IpStr1, &DNS->DnsServerIp[0].v6) > + SctStrToIPv6Addr (&IpStr2, &DNS->DnsServerIp[1].v6) Best regards Heinrich > } >=20 > return (EFI_DEVICE_PATH_PROTOCOL *) DNS; > -- > 2.27.0 -=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 (#115949): https://edk2.groups.io/g/devel/message/115949 Mute This Topic: https://groups.io/mt/104579419/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-