diff options
author | Volker Lendecke <vl@samba.org> | 2021-01-10 18:42:18 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2021-01-12 00:10:30 +0000 |
commit | 1b054aa0a52489ac183a47c2b2cdc66228d53738 (patch) | |
tree | b90f0f810624272b75db46bdb72367372ee8ead3 /source3/rpc_client | |
parent | ad5aabf8a1194269a25c68da6af991a489ba061c (diff) | |
download | samba-1b054aa0a52489ac183a47c2b2cdc66228d53738.tar.gz |
rpc_client: Simplify rpc_pipe_open_ncalrpc()
Consolidate close(fd)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/rpc_client')
-rw-r--r-- | source3/rpc_client/cli_pipe.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 040bd7cda90..8f52acadec8 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -2925,7 +2925,7 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path, socklen_t salen = sizeof(addr); size_t pathlen; NTSTATUS status; - int fd; + int fd = -1; pathlen = strlcpy(addr.sun_path, socket_path, sizeof(addr.sun_path)); if (pathlen >= sizeof(addr.sun_path)) { @@ -2966,15 +2966,14 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path, DEBUG(0, ("connect(%s) failed: %s\n", socket_path, strerror(errno))); status = map_nt_error_from_unix(errno); - close(fd); goto fail; } status = rpc_transport_sock_init(result, fd, &result->transport); if (!NT_STATUS_IS_OK(status)) { - close(fd); goto fail; } + fd = -1; result->transport->transport = NCALRPC; @@ -2988,6 +2987,9 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path, return NT_STATUS_OK; fail: + if (fd != -1) { + close(fd); + } TALLOC_FREE(result); return status; } |