From: Andreas Schneider Date: Thu, 13 Aug 2020 14:16:55 +0000 (+0200) Subject: s4:libcli: Return NTSTATUS errors for smb_composite_connect_send() X-Git-Tag: talloc-2.3.2~773 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2287011f4b654e085b9ddaa694b8ccdf8bfad30;p=thirdparty%2Fsamba.git s4:libcli: Return NTSTATUS errors for smb_composite_connect_send() Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 582d43ef173..ad50ae0ac81 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -420,15 +420,25 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec struct connect_state *state; c = talloc_zero(mem_ctx, struct composite_context); - if (c == NULL) goto failed; - - c->event_ctx = event_ctx; - if (c->event_ctx == NULL) goto failed; + if (c == NULL) { + goto nomem; + } state = talloc_zero(c, struct connect_state); - if (state == NULL) goto failed; + if (state == NULL) { + goto nomem; + } + + c->event_ctx = event_ctx; + if (c->event_ctx == NULL) { + composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX); + return c; + } - if (io->in.gensec_settings == NULL) goto failed; + if (io->in.gensec_settings == NULL) { + composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX); + return c; + } state->io = io; c->state = COMPOSITE_STATE_IN_PROGRESS; @@ -449,12 +459,14 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec &io->in.options, &state->transport); if (!NT_STATUS_IS_OK(status)) { - goto failed; + composite_error(c, status); + return c; } status = connect_send_session(c, io); if (!NT_STATUS_IS_OK(status)) { - goto failed; + composite_error(c, status); + return c; } return c; @@ -468,15 +480,18 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec io->in.socket_options, &state->calling, &state->called); - if (state->creq == NULL) goto failed; + if (state->creq == NULL) { + composite_error(c, NT_STATUS_NO_MEMORY); + return c; + } state->stage = CONNECT_SOCKET; state->creq->async.private_data = c; state->creq->async.fn = composite_handler; return c; -failed: - talloc_free(c); +nomem: + TALLOC_FREE(c); return NULL; } @@ -506,5 +521,8 @@ NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem struct tevent_context *ev) { struct composite_context *c = smb_composite_connect_send(io, mem_ctx, resolve_ctx, ev); + if (c == NULL) { + return NT_STATUS_NO_MEMORY; + } return smb_composite_connect_recv(c, mem_ctx); }