qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH v2 1/5] util/qemu-sockets: Fix GCC 9 build war


From: Alistair Francis
Subject: Re: [Qemu-trivial] [PATCH v2 1/5] util/qemu-sockets: Fix GCC 9 build warnings
Date: Thu, 2 May 2019 10:57:51 -0700

On Wed, May 1, 2019 at 2:41 AM Daniel P. Berrangé <address@hidden> wrote:
>
> On Tue, Apr 30, 2019 at 11:28:22PM +0000, Alistair Francis wrote:
> > Fix this warning when building with GCC9 on Fedora 30:
> > In function ‘strncpy’,
> >     inlined from ‘unix_connect_saddr.isra.0’ at util/qemu-sockets.c:925:5:
> > /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ 
> > specified bound 108 equals destination size [-Werror=stringop-truncation]
> >   106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos 
> > (__dest));
> >       |          
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > In function ‘strncpy’,
> >     inlined from ‘unix_listen_saddr.isra.0’ at util/qemu-sockets.c:880:5:
> >
> > Signed-off-by: Alistair Francis <address@hidden>
> > ---
> >  util/qemu-sockets.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> > index 9705051690..8c3322958f 100644
> > --- a/util/qemu-sockets.c
> > +++ b/util/qemu-sockets.c
> > @@ -829,7 +829,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
> >      struct sockaddr_un un;
> >      int sock, fd;
> >      char *pathbuf = NULL;
> > -    const char *path;
> > +    const char *path QEMU_NONSTRING;
> >
> >      sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
> >      if (sock < 0) {
> > @@ -922,7 +922,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, 
> > Error **errp)
> >
> >      memset(&un, 0, sizeof(un));
> >      un.sun_family = AF_UNIX;
> > -    strncpy(un.sun_path, saddr->path, sizeof(un.sun_path));
> > +    memcpy(un.sun_path, saddr->path, MIN(strlen(saddr->path), 
> > sizeof(un.sun_path)));
> >
> >      /* connect to peer */
> >      do {
>
> I think my proposed fix for this file is preferrable as it avoids
> repeated strlen calls
>
>   https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg02124.html

That's fine with me, I have dropped this patch.

Alistair

>
>
> Regards,
> Daniel
> --
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



reply via email to

[Prev in Thread] Current Thread [Next in Thread]