summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap/sdap_async_connection.c
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2016-06-16 17:40:50 +0200
committerLukas Slebodnik <lslebodn@redhat.com>2016-06-29 12:18:57 +0200
commitb54cd7caf6b73b36b68fcefc0cad39a626690398 (patch)
tree54e2e842cde33274d15b6554b144282ba33fa005 /src/providers/ldap/sdap_async_connection.c
parentbdadcaf271818e88e56e86c2bd90663a08fd9721 (diff)
downloadsssd-b54cd7caf6b73b36b68fcefc0cad39a626690398.tar.gz
sssd-b54cd7caf6b73b36b68fcefc0cad39a626690398.tar.xz
sssd-b54cd7caf6b73b36b68fcefc0cad39a626690398.zip
Downcast to errno_t after tevent_req_is_error
Functions tevent_req_is_error and _tevent_req_error use type uint64_t for error code. SSSD uses errno_t which is an alias for int. Therefore complier assumes that macro TEVENT_REQ_RETURN_ON_ERROR can return 0 due to implicit down casting from uint64_t -> int. This patch makes down casting explicit and returns EINVAL if result of downcasting is 0. Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/providers/ldap/sdap_async_connection.c')
-rw-r--r--src/providers/ldap/sdap_async_connection.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c
index 5045a1d19..a8d4262b5 100644
--- a/src/providers/ldap/sdap_async_connection.c
+++ b/src/providers/ldap/sdap_async_connection.c
@@ -1254,10 +1254,15 @@ static errno_t sdap_kinit_recv(struct tevent_req *req,
struct sdap_kinit_state *state = tevent_req_data(req,
struct sdap_kinit_state);
enum tevent_req_state tstate;
- uint64_t err = ERR_INTERNAL;
+ uint64_t err_uint64 = ERR_INTERNAL;
+ errno_t err;
- if (tevent_req_is_error(req, &tstate, &err)) {
+ if (tevent_req_is_error(req, &tstate, &err_uint64)) {
if (tstate != TEVENT_REQ_IN_PROGRESS) {
+ err = (errno_t)err_uint64;
+ if (err == EOK) {
+ return ERR_INTERNAL;
+ }
return err;
}
}
@@ -2027,16 +2032,17 @@ int sdap_cli_connect_recv(struct tevent_req *req,
struct sdap_cli_connect_state *state = tevent_req_data(req,
struct sdap_cli_connect_state);
enum tevent_req_state tstate;
- uint64_t err;
+ uint64_t err_uint64;
+ int err;
if (can_retry) {
*can_retry = true;
}
- if (tevent_req_is_error(req, &tstate, &err)) {
+ if (tevent_req_is_error(req, &tstate, &err_uint64)) {
/* mark the server as bad if connection failed */
if (state->srv) {
DEBUG(SSSDBG_OP_FAILURE, "Unable to establish connection "
- "[%"PRIu64"]: %s\n", err, sss_strerror(err));
+ "[%"PRIu64"]: %s\n", err_uint64, sss_strerror(err_uint64));
be_fo_set_port_status(state->be, state->service->name,
state->srv, PORT_NOT_WORKING);
@@ -2047,6 +2053,10 @@ int sdap_cli_connect_recv(struct tevent_req *req,
}
if (tstate == TEVENT_REQ_USER_ERROR) {
+ err = (int)err_uint64;
+ if (err == EOK) {
+ return EINVAL;
+ }
return err;
}
return EIO;