From: Ralph Boehme Date: Fri, 17 Jan 2020 18:30:18 +0000 (+0100) Subject: s3/lib: use talloc_alpha_strcpy() in sub_set_smb_name() X-Git-Tag: ldb-2.1.1~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8e218acd31381e821da9bf6c8d3379225c35cb7;p=thirdparty%2Fsamba.git s3/lib: use talloc_alpha_strcpy() in sub_set_smb_name() Signed-off-by: Ralph Boehme Reviewed-by: Andreas Schneider --- diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index acddb7dd165..7489a94c03d 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -172,19 +172,14 @@ void sub_set_smb_name(const char *name) } TALLOC_FREE(smb_user_name); - smb_user_name = (char *)TALLOC_ZERO(NULL, len+1); - if (!smb_user_name) { - TALLOC_FREE(tmp); + smb_user_name = talloc_alpha_strcpy(NULL, + tmp, + SAFE_NETBIOS_CHARS); + TALLOC_FREE(tmp); + if (smb_user_name == NULL) { return; } - /* alpha_strcpy includes the space for the terminating nul. */ - alpha_strcpy(smb_user_name, tmp, - SAFE_NETBIOS_CHARS, - len+1); - - TALLOC_FREE(tmp); - if (is_machine_account) { len = strlen(smb_user_name); smb_user_name[len-1] = '$';