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

Re: [Minios-devel] [UNIKRAFT PATCH] lib/sysinfo: Avoid stringop-overflow warning



Hi Simon, looks good, thanks.

Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>

On Fri, Feb 14, 2020 at 1:03 PM Simon Kuenzer <simon.kuenzer@xxxxxxxxx> wrote:
>
> Avoids the GCC warning: stringop-overflow. The length argument to
> `strncpy()` in `gethostname()` depend on a computed value done by
> `strlen()`. We fix this by taking the given `len` argument to the
> `strncpy()` operation instead.
>
> Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> ---
>  lib/posix-sysinfo/sysinfo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/posix-sysinfo/sysinfo.c b/lib/posix-sysinfo/sysinfo.c
> index 2bf2c12a..7bcfc8b3 100644
> --- a/lib/posix-sysinfo/sysinfo.c
> +++ b/lib/posix-sysinfo/sysinfo.c
> @@ -141,7 +141,7 @@ int gethostname(char *name, size_t len)
>                 return -1;
>         }
>
> -       strncpy(name, buf.nodename, node_len);
> +       strncpy(name, buf.nodename, len);
>
>         return 0;
>  }
> --
> 2.20.1
>
>
> _______________________________________________
> Minios-devel mailing list
> Minios-devel@xxxxxxxxxxxxxxxxxxxx
> https://lists.xenproject.org/mailman/listinfo/minios-devel

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.