All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Yuval Shaia <yuval.shaia.ml@gmail.com>
Subject: Re: [PATCH 2/2] hw/rdma: avoid suspicious strncpy() use
Date: Mon, 16 Mar 2020 18:28:33 +0100	[thread overview]
Message-ID: <87lfo0nr9a.fsf@secure.laptop> (raw)
In-Reply-To: <20200316160702.478964-3-stefanha@redhat.com> (Stefan Hajnoczi's message of "Mon, 16 Mar 2020 16:07:02 +0000")

Stefan Hajnoczi <stefanha@redhat.com> wrote:
> gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1) with sanitizers enabled
> reports the following error:
>
>   CC      x86_64-softmmu/hw/rdma/vmw/pvrdma_dev_ring.o
> In file included from /usr/include/string.h:495,
>                  from include/qemu/osdep.h:101,
>                  from hw/rdma/vmw/pvrdma_dev_ring.c:16:
> In function ‘strncpy’,
>     inlined from ‘pvrdma_ring_init’ at hw/rdma/vmw/pvrdma_dev_ring.c:33:5:
> /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 32 equals destination size [-Werror=stringop-truncation]
>   106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
>       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Use pstrcpy() instead of strncpy().  It is guaranteed to NUL-terminate
> strings.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>



  reply	other threads:[~2020-03-16 18:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-16 16:07 [PATCH 0/2] gcc 9.2 strncpy(3) warnings fixes Stefan Hajnoczi
2020-03-16 16:07 ` [PATCH 1/2] migration: avoid suspicious strncpy() use Stefan Hajnoczi
2020-03-16 17:25   ` Juan Quintela
2020-03-16 18:09   ` Philippe Mathieu-Daudé
2020-03-16 18:15     ` Eric Blake
2020-03-17  9:52       ` Stefan Hajnoczi
2020-03-17 10:12         ` Philippe Mathieu-Daudé
2020-03-17 10:35         ` Juan Quintela
2020-03-17 14:15           ` Stefan Hajnoczi
2020-03-17 14:18             ` Juan Quintela
2020-03-16 16:07 ` [PATCH 2/2] hw/rdma: " Stefan Hajnoczi
2020-03-16 17:28   ` Juan Quintela [this message]
2020-03-20 11:55   ` Yuval Shaia
2020-03-21 17:25     ` Marcel Apfelbaum

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=87lfo0nr9a.fsf@secure.laptop \
    --to=quintela@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=yuval.shaia.ml@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.