[Qemu-devel] [PATCH] target/ppc: fix compile error in kvmppc_define_rtas_kernel_token()

Cédric Le Goater posted 1 patch 4 years, 10 months ago
Test s390x passed
Test checkpatch passed
Test asan passed
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190615081252.28602-1-clg@kaod.org
Maintainers: David Gibson <david@gibson.dropbear.id.au>
target/ppc/kvm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] target/ppc: fix compile error in kvmppc_define_rtas_kernel_token()
Posted by Cédric Le Goater 4 years, 10 months ago
gcc9 reports :

In file included from /usr/include/string.h:494,
                 from ./include/qemu/osdep.h:101,
                 from ./target/ppc/kvm.c:17:
In function ‘strncpy’,
    inlined from ‘kvmppc_define_rtas_kernel_token’ at ./target/ppc/kvm.c:2648:5:
/usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 120 equals destination size [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 target/ppc/kvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index d4107dd70d21..9edf4abeaae7 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2645,7 +2645,7 @@ int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function)
         return -ENOENT;
     }
 
-    strncpy(args.name, function, sizeof(args.name));
+    strncpy(args.name, function, sizeof(args.name) - 1);
 
     return kvm_vm_ioctl(kvm_state, KVM_PPC_RTAS_DEFINE_TOKEN, &args);
 }
-- 
2.21.0


Re: [Qemu-devel] [PATCH] target/ppc: fix compile error in kvmppc_define_rtas_kernel_token()
Posted by David Gibson 4 years, 10 months ago
On Sat, Jun 15, 2019 at 10:12:52AM +0200, Cédric Le Goater wrote:
> gcc9 reports :
> 
> In file included from /usr/include/string.h:494,
>                  from ./include/qemu/osdep.h:101,
>                  from ./target/ppc/kvm.c:17:
> In function ‘strncpy’,
>     inlined from ‘kvmppc_define_rtas_kernel_token’ at ./target/ppc/kvm.c:2648:5:
> /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 120 equals destination size [-Werror=stringop-truncation]
>   106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
>       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Applied to ppc-for-4.1, thanks.

> ---
>  target/ppc/kvm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index d4107dd70d21..9edf4abeaae7 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -2645,7 +2645,7 @@ int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function)
>          return -ENOENT;
>      }
>  
> -    strncpy(args.name, function, sizeof(args.name));
> +    strncpy(args.name, function, sizeof(args.name) - 1);
>  
>      return kvm_vm_ioctl(kvm_state, KVM_PPC_RTAS_DEFINE_TOKEN, &args);
>  }

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson