From: Ralph Boehme Date: Fri, 17 Jan 2020 18:30:01 +0000 (+0100) Subject: s3/lib: use talloc_alpha_strcpy() in set_remote_machine_name() X-Git-Tag: ldb-2.1.1~173 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3cd8e46b3a32968a3d2c43ffb15daa57a068e55;p=thirdparty%2Fsamba.git s3/lib: use talloc_alpha_strcpy() in set_remote_machine_name() Signed-off-by: Ralph Boehme Reviewed-by: Andreas Schneider --- diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index ee079dc229d..acddb7dd165 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -94,7 +94,6 @@ bool set_remote_machine_name(const char *remote_name, bool perm) { static bool already_perm = False; char *tmp_remote_machine; - size_t len; if (already_perm) { return true; @@ -107,16 +106,12 @@ bool set_remote_machine_name(const char *remote_name, bool perm) trim_char(tmp_remote_machine,' ',' '); TALLOC_FREE(remote_machine); - len = strlen(tmp_remote_machine); - remote_machine = (char *)TALLOC_ZERO(NULL, len+1); - if (!remote_machine) { - TALLOC_FREE(tmp_remote_machine); + remote_machine = talloc_alpha_strcpy(NULL, + tmp_remote_machine, + SAFE_NETBIOS_CHARS); + if (remote_machine == NULL) { return false; } - - /* alpha_strcpy includes the space for the terminating nul. */ - alpha_strcpy(remote_machine,tmp_remote_machine, - SAFE_NETBIOS_CHARS,len+1); if (!strlower_m(remote_machine)) { TALLOC_FREE(tmp_remote_machine); return false;