]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/lib: use talloc_alpha_strcpy() in sub_set_smb_name()
authorRalph Boehme <slow@samba.org>
Fri, 17 Jan 2020 18:30:18 +0000 (19:30 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 6 Feb 2020 10:17:43 +0000 (10:17 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/lib/substitute.c

index acddb7dd16553e6b57a0ced5178686ae7c943476..7489a94c03dac7811294dc702e6792a785e8ace9 100644 (file)
@@ -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] = '$';