From e3cd8e46b3a32968a3d2c43ffb15daa57a068e55 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 Jan 2020 19:30:01 +0100 Subject: [PATCH] s3/lib: use talloc_alpha_strcpy() in set_remote_machine_name() Signed-off-by: Ralph Boehme Reviewed-by: Andreas Schneider --- source3/lib/substitute.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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; -- 2.47.2