diff --git a/src/curve_server.cpp b/src/curve_server.cpp index 631c15cd..8b693e43 100644 --- a/src/curve_server.cpp +++ b/src/curve_server.cpp @@ -491,23 +491,21 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_) // Use ZAP protocol (RFC 27) to authenticate the user. rc = session->zap_connect (); - if (rc == 0) { - rc = send_zap_request (client_key); - if (rc != 0) - return -1; - rc = receive_and_process_zap_reply (); - if (rc == 0) - state = status_code == "200" - ? send_ready - : send_error; - else - if (errno == EAGAIN) - state = expect_zap_reply; - else - return -1; - } + if (rc != 0) + return -1; + rc = send_zap_request (client_key); + if (rc != 0) + return -1; + rc = receive_and_process_zap_reply (); + if (rc == 0) + state = status_code == "200" + ? send_ready + : send_error; else - state = send_ready; + if (errno == EAGAIN) + state = expect_zap_reply; + else + return -1; return parse_metadata (initiate_plaintext + crypto_box_ZEROBYTES + 128, clen - crypto_box_ZEROBYTES - 128); diff --git a/src/gssapi_server.cpp b/src/gssapi_server.cpp index cf67bc26..2eaf1e25 100644 --- a/src/gssapi_server.cpp +++ b/src/gssapi_server.cpp @@ -120,20 +120,21 @@ int zmq::gssapi_server_t::process_handshake_command (msg_t *msg_) if (security_context_established) { // Use ZAP protocol (RFC 27) to authenticate the user. - bool expecting_zap_reply = false; int rc = session->zap_connect (); - if (rc == 0) { - rc = send_zap_request (); - if (rc != 0) - return -1; - rc = receive_and_process_zap_reply (); - if (rc != 0) { - if (errno != EAGAIN) - return -1; - expecting_zap_reply = true; - } - } - state = expecting_zap_reply? expect_zap_reply: send_ready; + if (rc != 0) + return -1; + rc = send_zap_request (); + if (rc != 0) + return -1; + rc = receive_and_process_zap_reply (); + if (rc == 0) + state = send_ready; + else + if (errno == EAGAIN) + state = expect_zap_reply; + else + return -1; + return 0; } diff --git a/src/plain_server.cpp b/src/plain_server.cpp index 55271344..23e13dc8 100644 --- a/src/plain_server.cpp +++ b/src/plain_server.cpp @@ -190,23 +190,21 @@ int zmq::plain_server_t::process_hello (msg_t *msg_) // Use ZAP protocol (RFC 27) to authenticate the user. int rc = session->zap_connect (); - if (rc == 0) { - rc = send_zap_request (username, password); - if (rc != 0) - return -1; - rc = receive_and_process_zap_reply (); - if (rc == 0) - state = status_code == "200" - ? sending_welcome - : sending_error; - else - if (errno == EAGAIN) - state = waiting_for_zap_reply; - else - return -1; - } + if (rc != 0) + return -1; + rc = send_zap_request (username, password); + if (rc != 0) + return -1; + rc = receive_and_process_zap_reply (); + if (rc == 0) + state = status_code == "200" + ? sending_welcome + : sending_error; else - state = sending_welcome; + if (errno == EAGAIN) + state = waiting_for_zap_reply; + else + return -1; return 0; }