[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for 2.10 31/35] syscall: replace strcpy() by g_s
From: |
Laurent Vivier |
Subject: |
Re: [Qemu-devel] [PATCH for 2.10 31/35] syscall: replace strcpy() by g_strlcpy() |
Date: |
Mon, 24 Jul 2017 21:28:44 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
Le 24/07/2017 à 20:27, Philippe Mathieu-Daudé a écrit :
> linux-user/syscall.c:9860:17: warning: Call to function 'strcpy' is insecure
> as it does not provide bounding of the memory buffer. Replace unbounded copy
> functions with analogous functions that support length arguments such as
> 'strlcpy'. CWE-119
> strcpy (buf->machine, cpu_to_uname_machine(cpu_env));
> ^~~~~~
>
> Reported-by: Clang Static Analyzer
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> linux-user/syscall.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 963b9c8f4b..847f729834 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -9853,7 +9853,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
> arg1,
> if (!is_error(ret)) {
> /* Overwrite the native machine name with whatever is being
> emulated. */
> - strcpy (buf->machine, cpu_to_uname_machine(cpu_env));
> + g_strlcpy(buf->machine, cpu_to_uname_machine(cpu_env),
> + sizeof(buf->machine));
> /* Allow the user to override the reported release. */
> if (qemu_uname_release && *qemu_uname_release) {
> g_strlcpy(buf->release, qemu_uname_release,
>
We should not have a problem here as cpu_to_uname_machine() is "const
char *" and the string is defined inside QEMU (so it should fit into
machine[]).
Reviewed-by: Laurent Vivier <address@hidden>
- Re: [Qemu-devel] [PATCH for 2.10 27/35] syscall: fix dereference of undefined pointer, (continued)
- [Qemu-devel] [PATCH for 2.10 28/35] syscall: check dup/dup2/dup3() errors, return EBADFD/EINVAL if required, Philippe Mathieu-Daudé, 2017/07/24
- [Qemu-devel] [PATCH for 2.10 29/35] syscall: fix out-of-bound memory access, Philippe Mathieu-Daudé, 2017/07/24
- [Qemu-devel] [PATCH for 2.10 30/35] syscall: fix use of uninitialized values, Philippe Mathieu-Daudé, 2017/07/24
- [Qemu-devel] [PATCH for 2.10 31/35] syscall: replace strcpy() by g_strlcpy(), Philippe Mathieu-Daudé, 2017/07/24
- Re: [Qemu-devel] [PATCH for 2.10 31/35] syscall: replace strcpy() by g_strlcpy(),
Laurent Vivier <=
- [Qemu-devel] [PATCH for 2.10 32/35] timer/pxa2xx: silent warning about out-of-bound memory access, Philippe Mathieu-Daudé, 2017/07/24
- [Qemu-devel] [RFC PATCH for 2.10 33/35] configure: clang does not support -Wexpansion-to-defined, Philippe Mathieu-Daudé, 2017/07/24
- [Qemu-devel] [RFC PATCH for 2.10 34/35] docker: add debian 'bleeding' image with gcc7 and clang5, Philippe Mathieu-Daudé, 2017/07/24