diff options
author | Andreas Schneider <asn@samba.org> | 2013-02-20 09:11:48 +0100 |
---|---|---|
committer | Alexander Bokovoy <ab@samba.org> | 2013-02-22 16:36:13 +0100 |
commit | f573826f18e590dd53a0795b670e6f30a3f5cd68 (patch) | |
tree | 381e23cb143c79e670c5c8987481731e276239bc /source3 | |
parent | c013df3ae52d57b1206f156a2fc529f52cf39531 (diff) | |
download | samba-f573826f18e590dd53a0795b670e6f30a3f5cd68.tar.gz |
s3-lsasd: Don't leak file descriptors.
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/rpc_server/lsasd.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/source3/rpc_server/lsasd.c b/source3/rpc_server/lsasd.c index a1ac49a47af..72ad785cd50 100644 --- a/source3/rpc_server/lsasd.c +++ b/source3/rpc_server/lsasd.c @@ -598,7 +598,7 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx, TALLOC_CTX *tmp_ctx; NTSTATUS status; uint32_t i; - int fd; + int fd = -1; int rc; bool ok = true; @@ -641,8 +641,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx, ok = false; goto done; } - listen_fd[*listen_fd_size] = fd; - (*listen_fd_size)++; rc = listen(fd, pf_lsasd_cfg.max_allowed_clients); if (rc == -1) { @@ -651,14 +649,14 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx, ok = false; goto done; } + listen_fd[*listen_fd_size] = fd; + (*listen_fd_size)++; fd = create_named_pipe_socket("lsass"); if (fd < 0) { ok = false; goto done; } - listen_fd[*listen_fd_size] = fd; - (*listen_fd_size)++; rc = listen(fd, pf_lsasd_cfg.max_allowed_clients); if (rc == -1) { @@ -667,14 +665,14 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx, ok = false; goto done; } + listen_fd[*listen_fd_size] = fd; + (*listen_fd_size)++; fd = create_dcerpc_ncalrpc_socket("lsarpc"); if (fd < 0) { ok = false; goto done; } - listen_fd[*listen_fd_size] = fd; - (*listen_fd_size)++; rc = listen(fd, pf_lsasd_cfg.max_allowed_clients); if (rc == -1) { @@ -683,6 +681,9 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx, ok = false; goto done; } + listen_fd[*listen_fd_size] = fd; + (*listen_fd_size)++; + fd = -1; v = dcerpc_binding_vector_dup(tmp_ctx, v_orig); if (v == NULL) { @@ -735,8 +736,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx, ok = false; goto done; } - listen_fd[*listen_fd_size] = fd; - (*listen_fd_size)++; rc = listen(fd, pf_lsasd_cfg.max_allowed_clients); if (rc == -1) { @@ -745,6 +744,9 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx, ok = false; goto done; } + listen_fd[*listen_fd_size] = fd; + (*listen_fd_size)++; + fd = -1; v = dcerpc_binding_vector_dup(tmp_ctx, v_orig); if (v == NULL) { @@ -797,16 +799,18 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx, ok = false; goto done; } - listen_fd[*listen_fd_size] = fd; - (*listen_fd_size)++; rc = listen(fd, pf_lsasd_cfg.max_allowed_clients); if (rc == -1) { DEBUG(0, ("Failed to listen on netlogon ncalrpc - %s\n", strerror(errno))); + close(fd); ok = false; goto done; } + listen_fd[*listen_fd_size] = fd; + (*listen_fd_size)++; + fd = -1; v = dcerpc_binding_vector_dup(tmp_ctx, v_orig); if (v == NULL) { @@ -838,6 +842,9 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx, } done: + if (fd != -1) { + close(fd); + } talloc_free(tmp_ctx); return ok; } |