From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: mrezanin@redhat.com, qemu-devel@nongnu.org
Cc: Zenghui Yu <yuzenghui@huawei.com>,
"Daniel P . Berrange" <berrange@redhat.com>,
Thomas Huth <thuth@redhat.com>,
Jagannathan Raman <jag.raman@oracle.com>
Subject: Re: [PATCH] Add missing initialization for g_autofree variables
Date: Fri, 12 Mar 2021 14:49:16 +0100 [thread overview]
Message-ID: <a93e4e14-bc86-ef7f-26dd-83d3a0754732@redhat.com> (raw)
In-Reply-To: <20210312120309.138913-1-mrezanin@redhat.com>
On 3/12/21 1:03 PM, mrezanin@redhat.com wrote:
> From: Miroslav Rezanina <mrezanin@redhat.com>
>
> When declaring g_autofree variable without inicialization, compiler
> will raise "may be used uninitialized in this function" warning due
> to automatic free handling. This usage can cause gfree using unknown.
> Such behavior can be dangerous and exploitable.
Will we be able to catch that earlier when building using
the Fedora/rawhide Docker image?
>
> Add inicialization to NULL for these declaration to ensure uninitialized
> value is not used.
>
> Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
> ---
> hw/remote/memory.c | 2 +-
> hw/remote/proxy.c | 2 +-
> hw/s390x/s390-pci-vfio.c | 4 ++--
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/hw/remote/memory.c b/hw/remote/memory.c
> index 32085b1e05..bf0047a81b 100644
> --- a/hw/remote/memory.c
> +++ b/hw/remote/memory.c
> @@ -43,7 +43,7 @@ void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp)
> remote_sysmem_reset();
>
> for (region = 0; region < msg->num_fds; region++) {
> - g_autofree char *name;
> + g_autofree char *name = NULL;
> subregion = g_new(MemoryRegion, 1);
> name = g_strdup_printf("remote-mem-%u", suffix++);
There is a reviewed patch for this one:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg787631.html
prev parent reply other threads:[~2021-03-12 13:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 12:03 [PATCH] Add missing initialization for g_autofree variables mrezanin
2021-03-12 13:49 ` Philippe Mathieu-Daudé [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-all 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=a93e4e14-bc86-ef7f-26dd-83d3a0754732@redhat.com \
--to=philmd@redhat.com \
--cc=berrange@redhat.com \
--cc=jag.raman@oracle.com \
--cc=mrezanin@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
--cc=yuzenghui@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).