diff options
author | Andrew Bartlett <abartlet@samba.org> | 2013-01-09 08:02:23 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2013-01-09 14:54:22 +1100 |
commit | 97eb0493fc263fabe63b6846b6f6add7068098e6 (patch) | |
tree | 66d6c12ab8087ab407940671ca466e38c91d45d1 /source3 | |
parent | 3d5c534f0cc7c6e3eead7462eef4a178c7035857 (diff) | |
download | samba-97eb0493fc263fabe63b6846b6f6add7068098e6.tar.gz samba-97eb0493fc263fabe63b6846b6f6add7068098e6.tar.bz2 samba-97eb0493fc263fabe63b6846b6f6add7068098e6.zip |
smbd: Rework create_conn_struct to use conn_new()
This avoids issues with required structure elements not being initialised.
In particular, once conn->vuid_cache becomes a pointer, this ensures
that it is initalised in all cases.
Andrew Bartlett
Reviewed by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/msdfs.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index e8a0610d74..8e80cbb764 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -234,12 +234,29 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx, connection_struct *conn; char *connpath; const char *vfs_user; + struct smbd_server_connection *sconn; - conn = talloc_zero(ctx, connection_struct); + sconn = talloc_zero(ctx, struct smbd_server_connection); + if (sconn == NULL) { + return NT_STATUS_NO_MEMORY; + } + + sconn->ev_ctx = ev; + sconn->msg_ctx = msg; + sconn->sock = -1; + sconn->smb1.echo_handler.trusted_fd = -1; + sconn->smb1.echo_handler.socket_lock_fd = -1; + + conn = conn_new(sconn); if (conn == NULL) { + TALLOC_FREE(sconn); return NT_STATUS_NO_MEMORY; } + /* Now we have conn, we need to make sconn a child of conn, + * for a proper talloc tree */ + talloc_steal(conn, sconn); + connpath = talloc_strdup(conn, path); if (!connpath) { TALLOC_FREE(conn); @@ -254,32 +271,11 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx, return NT_STATUS_NO_MEMORY; } - conn->sconn = talloc_zero(conn, struct smbd_server_connection); - if (conn->sconn == NULL) { - TALLOC_FREE(conn); - return NT_STATUS_NO_MEMORY; - } - - conn->sconn->ev_ctx = ev; - conn->sconn->msg_ctx = msg; - conn->sconn->sock = -1; - conn->sconn->smb1.echo_handler.trusted_fd = -1; - conn->sconn->smb1.echo_handler.socket_lock_fd = -1; - /* needed for smbd_vfs_init() */ - if (!(conn->params = talloc_zero(conn, struct share_params))) { - DEBUG(0, ("TALLOC failed\n")); - TALLOC_FREE(conn); - return NT_STATUS_NO_MEMORY; - } - conn->params->service = snum; conn->cnum = TID_FIELD_INVALID; - DLIST_ADD(conn->sconn->connections, conn); - conn->sconn->num_connections++; - if (session_info != NULL) { conn->session_info = copy_session_info(conn, session_info); if (conn->session_info == NULL) { |