From: Andreas Schneider Date: Wed, 9 May 2018 15:29:39 +0000 (+0200) Subject: s3:lib: Use memcpy() in escape_ldap_string() X-Git-Tag: ldb-1.4.0~128 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff7568daaeb19ff30f47f7f600ead247eaf4e826;p=thirdparty%2Fsamba.git s3:lib: Use memcpy() in escape_ldap_string() ../source3/lib/ldap_escape.c: In function ‘escape_ldap_string’: ../source3/lib/ldap_escape.c:79:4: error: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Werror=stringop-truncation] strncpy (p, sub, 3); ^~~~~~~~~~~~~~~~~~~ We concatenat and do not care about NUL-termination till the loop has finished. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437 Signed-off-by: Andreas Schneider Reviewed-by: Guenther Deschner --- diff --git a/source3/lib/ldap_escape.c b/source3/lib/ldap_escape.c index fa75dabcae6..0d2b8f5fe01 100644 --- a/source3/lib/ldap_escape.c +++ b/source3/lib/ldap_escape.c @@ -76,7 +76,7 @@ char *escape_ldap_string(TALLOC_CTX *mem_ctx, const char *s) output = tmp; p = &output[i]; - strncpy (p, sub, 3); + memcpy(p, sub, 3); p += 3; i += 3;