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 1/2] migration: avoid suspicious strncpy() use
Date: Mon, 16 Mar 2020 18:25:04 +0100 [thread overview]
Message-ID: <87pndcnrf3.fsf@secure.laptop> (raw)
In-Reply-To: <20200316160702.478964-2-stefanha@redhat.com> (Stefan Hajnoczi's message of "Mon, 16 Mar 2020 16:07:01 +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 migration/global_state.o
> In file included from /usr/include/string.h:495,
> from /home/stefanha/qemu/include/qemu/osdep.h:101,
> from migration/global_state.c:13:
> In function ‘strncpy’,
> inlined from ‘global_state_store_running’ at migration/global_state.c:47:5:
> /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 100 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>
This is the film where:
- one put a size 100
- none of the current elements has a size of 20
- for extra security one put one assert to make sure tha there are
space.
And compiler still find a reason for complaining O:-)
next prev parent reply other threads:[~2020-03-16 18:44 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 [this message]
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
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=87pndcnrf3.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.