From d99b7d0b0131d6474696bdab67375c4606137d9e Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Fri, 13 Nov 2020 14:22:48 +0200 Subject: [PATCH] ipa-sam: fix gcc complaints on Rawhide In file included from /usr/include/string.h:519, from /usr/include/lber.h:30, from /usr/include/ldap.h:30, from ipa_sam.c:12: In function 'strncpy', inlined from 'save_sid_to_secret' at ipa_sam.c:4478:2, inlined from 'pdb_init_ipasam' at ipa_sam.c:4985:12: /usr/include/bits/string_fortified.h:91:10: warning: 'strncpy' specified bound 255 equals destination size [-Wstringop-truncation] 91 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: https://pagure.io/freeipa/issue/8585 Signed-off-by: Alexander Bokovoy Reviewed-By: Rob Crittenden --- daemons/ipa-sam/ipa_sam.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemons/ipa-sam/ipa_sam.c b/daemons/ipa-sam/ipa_sam.c index 5dbdc17fb..79f4e5a77 100644 --- a/daemons/ipa-sam/ipa_sam.c +++ b/daemons/ipa-sam/ipa_sam.c @@ -4441,7 +4441,7 @@ static char *sec_key(TALLOC_CTX *mem_ctx, const char *d) static NTSTATUS save_sid_to_secret(struct ipasam_private *ipasam_state) { - char hostname[IPA_HOST_FQDN_LEN]; + char hostname[IPA_HOST_FQDN_LEN + 1]; const char *fqdn; char *p; TALLOC_CTX *tmp_ctx; @@ -4475,7 +4475,7 @@ static NTSTATUS save_sid_to_secret(struct ipasam_private *ipasam_state) } /* Copy is necessary, otherwise we this will corrupt the static * buffer returned by ipa_gethostfqdn(). */ - strncpy(hostname, fqdn, sizeof(hostname)); + strncpy(hostname, fqdn, IPA_HOST_FQDN_LEN); p = strchr(hostname, '.'); if (p != NULL) { *p = '\0';