Skip to content

Commit

Permalink
s3:lib: Use memcpy() in escape_ldap_string()
Browse files Browse the repository at this point in the history
../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 <[email protected]>
Reviewed-by: Guenther Deschner <[email protected]>
  • Loading branch information
cryptomilk committed May 17, 2018
1 parent 7a00d90 commit ff7568d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source3/lib/ldap_escape.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ff7568d

Please sign in to comment.