From: "Heinrich Schuchardt" <heinrich.schuchardt@canonical.com>
To: Chao Li <lichao@loongson.cn>
Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>,
Barton Gao <gaojie@byosoft.com.cn>,
Carolyn Gjertsen <Carolyn.Gjertsen@amd.com>,
Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>,
Eric Jin <eric.jin@intel.com>, Arvin Chen <arvinx.chen@intel.com>,
Supreeth Venkatesh <Supreeth.Venkatesh@amd.com>,
devel@edk2.groups.io
Subject: Re: [edk2-devel] [edk2-test v2] SctPkg: Fixed a pinter error in DevicePathFromTextBBTestCoverage.c
Date: Tue, 27 Feb 2024 15:04:06 +0100 [thread overview]
Message-ID: <b8b5ccab-6859-4f99-9cc3-77907086fc42@canonical.com> (raw)
In-Reply-To: <20240227063737.1675884-1-lichao@loongson.cn>
On 27.02.24 07:37, Chao Li wrote:
> DevicePathFromTextBBTextCoverage.c function CreateDNSDeviceNode has a
> bug, code:
>
> SctStrToIPv4Addr (&IpStr1, (EFI_IPv4_ADDRESS *)(DNS + sizeof (DNS_DEVICE_PATH)));
>
> 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.
>
> Fixes: 847e0363e846 ("SctPkg: Fix the UefiSct-Wincompatible-pointer-types warnings")
>
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4712
>
> Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>
> Cc: Barton Gao <gaojie@byosoft.com.cn>
> Cc: Carolyn Gjertsen <Carolyn.Gjertsen@amd.com>
> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
> Cc: Eric Jin <eric.jin@intel.com>
> Cc: Arvin Chen <arvinx.chen@intel.com>
> Cc: Supreeth Venkatesh <Supreeth.Venkatesh@amd.com>
> Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Signed-off-by: Chao Li <lichao@loongson.cn>
> ---
> .../BlackBoxTest/DevicePathFromTextBBTestCoverage.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathFromText/BlackBoxTest/DevicePathFromTextBBTestCoverage.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathFromText/BlackBoxTest/DevicePathFromTextBBTestCoverage.c
> index c96ee246..bd11c25a 100644
> --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathFromText/BlackBoxTest/DevicePathFromTextBBTestCoverage.c
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathFromText/BlackBoxTest/DevicePathFromTextBBTestCoverage.c
> @@ -1734,13 +1734,13 @@ CreateDNSDeviceNode (
> }
>
> if (DNS->IsIPv6 == 0) {
> - SctStrToIPv4Addr (&IpStr1, (EFI_IPv4_ADDRESS *)(DNS + sizeof (DNS_DEVICE_PATH)));
> - SctStrToIPv4Addr (&IpStr2, (EFI_IPv4_ADDRESS *)(DNS + sizeof (DNS_DEVICE_PATH) + sizeof(EFI_IP_ADDRESS)));
> + SctStrToIPv4Addr (&IpStr1, (EFI_IPv4_ADDRESS *)((UINT8 *)DNS + sizeof (DNS_DEVICE_PATH)));
> + SctStrToIPv4Addr (&IpStr2, (EFI_IPv4_ADDRESS *)((UINT8 *)DNS + sizeof (DNS_DEVICE_PATH) + sizeof(EFI_IP_ADDRESS)));
> }
>
> if (DNS->IsIPv6 == 1) {
> - SctStrToIPv6Addr (&IpStr1, (EFI_IPv6_ADDRESS *)(DNS + sizeof (DNS_DEVICE_PATH)));
> - SctStrToIPv6Addr (&IpStr2, (EFI_IPv6_ADDRESS *)(DNS + sizeof (DNS_DEVICE_PATH) + sizeof(EFI_IP_ADDRESS)));
> + SctStrToIPv6Addr (&IpStr1, (EFI_IPv6_ADDRESS *)((UINT8 *)DNS + sizeof (DNS_DEVICE_PATH)));
> + SctStrToIPv6Addr (&IpStr2, (EFI_IPv6_ADDRESS *)((UINT8 *)DNS + sizeof (DNS_DEVICE_PATH) + sizeof(EFI_IP_ADDRESS)));
> }
>
> return (EFI_DEVICE_PATH_PROTOCOL *) DNS;
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116044): https://edk2.groups.io/g/devel/message/116044
Mute This Topic: https://groups.io/mt/104598721/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
prev parent reply other threads:[~2024-02-27 14:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 6:37 [edk2-devel] [edk2-test v2] SctPkg: Fixed a pinter error in DevicePathFromTextBBTestCoverage.c Chao Li
2024-02-27 7:50 ` G Edhaya Chandran
2024-02-27 8:03 ` Chao Li
2024-02-27 9:19 ` G Edhaya Chandran
2024-02-27 9:25 ` Chao Li
2024-02-27 10:29 ` G Edhaya Chandran
2024-02-27 14:04 ` Heinrich Schuchardt [this message]
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=b8b5ccab-6859-4f99-9cc3-77907086fc42@canonical.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