qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 1/2] migration: avoid suspicious strncpy() use


From: Juan Quintela
Subject: Re: [PATCH 1/2] migration: avoid suspicious strncpy() use
Date: Mon, 16 Mar 2020 18:25:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Stefan Hajnoczi <address@hidden> 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 <address@hidden>

Reviewed-by: Juan Quintela <address@hidden>

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:-)




reply via email to

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