From: Ralph Boehme Date: Fri, 17 Jan 2020 18:28:54 +0000 (+0100) Subject: s3/lib: use talloc_alpha_strcpy() in set_local_machine_name() X-Git-Tag: ldb-2.1.1~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a8e6271c61400565b665584edace2e7cce8eb84;p=thirdparty%2Fsamba.git s3/lib: use talloc_alpha_strcpy() in set_local_machine_name() Signed-off-by: Ralph Boehme Reviewed-by: Andreas Schneider --- diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index b5e08e0aa55..ee079dc229d 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -44,7 +44,6 @@ bool set_local_machine_name(const char *local_name, bool perm) { static bool already_perm = false; char *tmp_local_machine = NULL; - size_t len; if (already_perm) { return true; @@ -57,15 +56,12 @@ bool set_local_machine_name(const char *local_name, bool perm) trim_char(tmp_local_machine,' ',' '); TALLOC_FREE(local_machine); - len = strlen(tmp_local_machine); - local_machine = (char *)TALLOC_ZERO(NULL, len+1); - if (!local_machine) { - TALLOC_FREE(tmp_local_machine); + local_machine = talloc_alpha_strcpy(NULL, + tmp_local_machine, + SAFE_NETBIOS_CHARS); + if (local_machine == NULL) { return false; } - /* alpha_strcpy includes the space for the terminating nul. */ - alpha_strcpy(local_machine,tmp_local_machine, - SAFE_NETBIOS_CHARS,len+1); if (!strlower_m(local_machine)) { TALLOC_FREE(tmp_local_machine); return false;