[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: |
Laurent Vivier |
Subject: |
Re: [Qemu-trivial] [PATCH v1 5/5] linux-user/elfload: Fix GCC 9 build warnings |
Date: |
Tue, 30 Apr 2019 22:36:44 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
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 :)
>
> 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?
> fill_auxv_note(&info->notes[2], ts);
> info->numnote = 3;
>
>
Thanks,
Laurent
- [Qemu-trivial] [PATCH v1 2/5] hw/usb/hcd-xhci: Fix GCC 9 build warning, (continued)
[Qemu-trivial] [PATCH v1 3/5] hw/usb/dev-mtp: Fix GCC 9 build warning, Alistair Francis, 2019/04/30
[Qemu-trivial] [PATCH v1 1/5] util/qemu-sockets: Fix GCC 9 build warnings, Alistair Francis, 2019/04/30