s4:ldap_server: make the gensec_create_tstream() error checking more clear
authorStefan Metzmacher <metze@samba.org>
Fri, 12 May 2017 10:26:12 +0000 (12:26 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 15 Jun 2017 07:13:24 +0000 (09:13 +0200)
Check with 'git show -w'.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/ldap_server/ldap_bind.c

index 352e67da1a7872b991cd87812dca394e6bcf370b..cd6b7e43f96425c16b2e5472a52f25b3edb2cfe8 100644 (file)
@@ -499,21 +499,20 @@ static NTSTATUS ldapsrv_BindSASL(struct ldapsrv_call *call)
                                               context->conn->gensec,
                                               context->conn->sockets.raw,
                                               &context->sasl);
-               if (NT_STATUS_IS_OK(status)) {
-                       if (!talloc_reference(context->sasl, conn->gensec)) {
-                               return NT_STATUS_NO_MEMORY;
-                       }
-               }
-       }
-
-       if (!NT_STATUS_IS_OK(status)) {
-               result = LDAP_OPERATIONS_ERROR;
-               errstr = talloc_asprintf(reply,
+               if (!NT_STATUS_IS_OK(status)) {
+                       result = LDAP_OPERATIONS_ERROR;
+                       errstr = talloc_asprintf(reply,
                                         "SASL:[%s]: Failed to setup SASL socket: %s",
                                         req->creds.SASL.mechanism, nt_errstr(status));
-               goto do_reply;
-       } else {
+                       goto do_reply;
+               }
 
+               if (!talloc_reference(context->sasl, conn->gensec)) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+       }
+
+       {
                status = gensec_session_info(conn->gensec, call, &session_info);
                if (!NT_STATUS_IS_OK(status)) {
                        result = LDAP_OPERATIONS_ERROR;