auth/auth_sam_reply: do a real copy of strings in auth_convert_user_info_dc_sambaseinfo()
authorStefan Metzmacher <metze@samba.org>
Thu, 7 Jan 2016 14:46:10 +0000 (15:46 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 30 Jun 2016 01:30:27 +0000 (03:30 +0200)
That's much more expected by callers.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
auth/auth_sam_reply.c

index b325586..cfdd533 100644 (file)
@@ -66,12 +66,23 @@ NTSTATUS auth_convert_user_info_dc_sambaseinfo(TALLOC_CTX *mem_ctx,
        sam->allow_password_change = info->allow_password_change;
        sam->force_password_change = info->force_password_change;
 
-       sam->account_name.string = info->account_name;
-       sam->full_name.string = info->full_name;
-       sam->logon_script.string = info->logon_script;
-       sam->profile_path.string = info->profile_path;
-       sam->home_directory.string = info->home_directory;
-       sam->home_drive.string = info->home_drive;
+#define _COPY_STRING_TALLOC(src_name, dst_name) do { \
+       if (info->src_name != NULL) {\
+               sam->dst_name.string = talloc_strdup(sam, info->src_name); \
+               if (sam->dst_name.string == NULL) { \
+                       return NT_STATUS_NO_MEMORY; \
+               } \
+       } \
+} while(0)
+       _COPY_STRING_TALLOC(account_name, account_name);
+       _COPY_STRING_TALLOC(full_name, full_name);
+       _COPY_STRING_TALLOC(logon_script, logon_script);
+       _COPY_STRING_TALLOC(profile_path, profile_path);
+       _COPY_STRING_TALLOC(home_directory, home_directory);
+       _COPY_STRING_TALLOC(home_drive, home_drive);
+       _COPY_STRING_TALLOC(logon_server, logon_server);
+       _COPY_STRING_TALLOC(domain_name, logon_domain);
+#undef _COPY_STRING_TALLOC
 
        sam->logon_count = info->logon_count;
        sam->bad_password_count = info->bad_password_count;
@@ -106,8 +117,6 @@ NTSTATUS auth_convert_user_info_dc_sambaseinfo(TALLOC_CTX *mem_ctx,
                sam->user_flags |= NETLOGON_GUEST;
        }
        sam->acct_flags = user_info_dc->info->acct_flags;
-       sam->logon_server.string = user_info_dc->info->logon_server;
-       sam->logon_domain.string = user_info_dc->info->domain_name;
        sam->sub_auth_status = 0;
        sam->last_successful_logon = 0;
        sam->last_failed_logon = 0;