winbind: avoid using fstrcpy(dcname,...) in _dual_init_connection
authorStefan Metzmacher <metze@samba.org>
Thu, 15 Feb 2018 15:00:33 +0000 (16:00 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 23 Feb 2018 03:09:18 +0000 (04:09 +0100)
domain->dcname was converted from fstring to char * by commit
14bae61ba36814ea5eca7c51cf1cc039e9e6803f.

Luckily this was only ever called with an empty string in
state->request->data.init_conn.dcname.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13294

Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/winbindd/winbindd_util.c

index 6292cce9d51dbf1e4a913fd0bb8eadc2f1ab7b8a..9950c669629da80001a747efdfe729f44a2bfd90 100644 (file)
@@ -781,7 +781,12 @@ enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domai
                [sizeof(state->request->data.init_conn.dcname)-1]='\0';
 
        if (strlen(state->request->data.init_conn.dcname) > 0) {
-               fstrcpy(domain->dcname, state->request->data.init_conn.dcname);
+               TALLOC_FREE(domain->dcname);
+               domain->dcname = talloc_strdup(domain,
+                               state->request->data.init_conn.dcname);
+               if (domain->dcname == NULL) {
+                       return WINBINDD_ERROR;
+               }
        }
 
        init_dc_connection(domain, false);