qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [PATCH v1 5/5] linux-user/elfload: Fix GCC 9 build wa


From: Alistair Francis
Subject: Re: [Qemu-trivial] [PATCH v1 5/5] linux-user/elfload: Fix GCC 9 build warnings
Date: Tue, 30 Apr 2019 14:01:35 -0700

On Tue, Apr 30, 2019 at 1:36 PM Laurent Vivier <address@hidden> wrote:
>
> Le 30/04/2019 à 22:09, Alistair Francis a écrit :
> > Fix this warning when building with GCC9 on Fedora 30:
> > In function ‘strncpy’,
> >     inlined from ‘fill_psinfo’ at 
> > /home/alistair/qemu/linux-user/elfload.c:3208:12,
> >     inlined from ‘fill_note_info’ at 
> > /home/alistair/qemu/linux-user/elfload.c:3390:5,
> >     inlined from ‘elf_core_dump’ at 
> > /home/alistair/qemu/linux-user/elfload.c:3539:9:
> > /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ 
> > specified bound 16 equals destination size [-Werror=stringop-truncation]
> >   106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos 
> > (__dest));
> >       |          
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Signed-off-by: Alistair Francis <address@hidden>
> > ---
> >  linux-user/elfload.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> > index c1a26021f8..cbb7fc10fa 100644
> > --- a/linux-user/elfload.c
> > +++ b/linux-user/elfload.c
> > @@ -3206,7 +3206,7 @@ static int fill_psinfo(struct target_elf_prpsinfo 
> > *psinfo, const TaskState *ts)
>
>        /*
>         * Using strncpy here is fine: at max-length,
> >       * this field is not NUL-terminated.
> >       */>      (void) strncpy(psinfo->pr_fname, base_filename,
> > -                   sizeof(psinfo->pr_fname));
> > +                   sizeof(psinfo->pr_fname) - 1);
>
> Read the comment above :)

GCC can't read the comment though. The only other option I can think
of is using a pragma, which I avoided using unless I had to. Would you
prefer a pragma here? Or do you have a better solution?

>
> >
> >      g_free(base_filename);
> >      bswap_psinfo(psinfo);
> > @@ -3389,7 +3389,7 @@ static int fill_note_info(struct elf_note_info *info,
> >                sizeof (*info->prstatus), info->prstatus);
> >      fill_psinfo(info->psinfo, ts);
> >      fill_note(&info->notes[1], "CORE", NT_PRPSINFO,
> > -              sizeof (*info->psinfo), info->psinfo);
> > +              sizeof(*info->psinfo) - 1, info->psinfo);
>
> Why?

Same issue as above.

Alistair

>
> >      fill_auxv_note(&info->notes[2], ts);
> >      info->numnote = 3;
> >
> >
>
> Thanks,
> Laurent



reply via email to

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