mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-26 16:16:31 -06:00
Don't abuse strncpy() length limitation
On two occasions C code abused strncpy()'s length limitation to copy a string of known length without the trailing NULL byte. Recent GCC is raising the compiler warning: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] Use memcpy() instead if strncpy() to copy data of known size. See: https://pagure.io/freeipa/issue/7738 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
parent
836e29591c
commit
5fe3198d80
@ -110,7 +110,7 @@ static char *ipadb_realm_to_ldapi_uri(char *realm)
|
||||
/* copy path and escape '/' to '%2f' */
|
||||
for (q = LDAPIDIR; *q; q++) {
|
||||
if (*q == '/') {
|
||||
strncpy(p, "%2f", 3);
|
||||
memcpy(p, "%2f", 3);
|
||||
p += 3;
|
||||
} else {
|
||||
*p = *q;
|
||||
|
@ -1003,7 +1003,7 @@ int ipapwd_set_extradata(const char *dn,
|
||||
xdata[5] = (unixtime & 0xff000000) >> 24;
|
||||
|
||||
/* append the principal name */
|
||||
strncpy(&xdata[6], principal, p_len);
|
||||
memcpy(&xdata[6], principal, p_len);
|
||||
|
||||
xdata[xd_len -1] = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user