summaryrefslogtreecommitdiffstats
path: root/src/providers/dp_auth_util.c
diff options
context:
space:
mode:
authorStef Walter <stefw@redhat.com>2014-02-24 09:58:15 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-03-14 14:05:34 +0100
commite657a39250e39294de17a067ac1972839b902d81 (patch)
treef26260ff19abb0ec75edb881d9c3d420a5c5c89b /src/providers/dp_auth_util.c
parent0a7b7059d7e6dc6566a3aa2201960b61afdf2758 (diff)
downloadsssd-e657a39250e39294de17a067ac1972839b902d81.tar.gz
sssd-e657a39250e39294de17a067ac1972839b902d81.tar.xz
sssd-e657a39250e39294de17a067ac1972839b902d81.zip
providers: Fix types passed to dbus varargs functions
Fix some incorrect types passed to dbus_message_get_args(), dbus_message_append_args() or functions accepting similar varargs and types. In particular sizeof(bool) != sizeof(dbus_bool_t) on most platforms. This probably only worked because the compiler was aligning stack variables and so writing off the end of one of them wasn't the end of the world. In addition fix cases where int != int32_t != uint32_t. Although these will work on many common platforms, assuming these are interchangeable is not cross platform safe. Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com> Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com> (cherry picked from commit 5bad17538eab85ce69e0355cd25b52b4a473cc36)
Diffstat (limited to 'src/providers/dp_auth_util.c')
-rw-r--r--src/providers/dp_auth_util.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/providers/dp_auth_util.c b/src/providers/dp_auth_util.c
index 0bf10a7d2..3bcd797ef 100644
--- a/src/providers/dp_auth_util.c
+++ b/src/providers/dp_auth_util.c
@@ -29,11 +29,13 @@ bool dp_pack_pam_request(DBusMessage *msg, struct pam_data *pd)
const char *ruser;
const char *rhost;
uint32_t authtok_type;
- uint32_t authtok_length;
+ int authtok_length;
uint8_t *authtok_data;
uint32_t new_authtok_type;
- uint32_t new_authtok_length;
+ int new_authtok_length;
uint8_t *new_authtok_data;
+ int32_t pd_priv;
+ int32_t pd_cmd;
if (pd->user == NULL) return false;
service = pd->service ? pd->service : "";
@@ -46,9 +48,11 @@ bool dp_pack_pam_request(DBusMessage *msg, struct pam_data *pd)
new_authtok_type = (uint32_t)sss_authtok_get_type(pd->newauthtok);
new_authtok_data = sss_authtok_get_data(pd->newauthtok);
new_authtok_length = sss_authtok_get_size(pd->newauthtok);
+ pd_priv = pd->priv;
+ pd_cmd = pd->cmd;
db_ret = dbus_message_append_args(msg,
- DBUS_TYPE_INT32, &(pd->cmd),
+ DBUS_TYPE_INT32, &pd_cmd,
DBUS_TYPE_STRING, &(pd->user),
DBUS_TYPE_STRING, &(pd->domain),
DBUS_TYPE_STRING, &service,
@@ -61,7 +65,7 @@ bool dp_pack_pam_request(DBusMessage *msg, struct pam_data *pd)
DBUS_TYPE_UINT32, &new_authtok_type,
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
&new_authtok_data, new_authtok_length,
- DBUS_TYPE_INT32, &(pd->priv),
+ DBUS_TYPE_INT32, &pd_priv,
DBUS_TYPE_UINT32, &(pd->cli_pid),
DBUS_TYPE_INVALID);
@@ -75,16 +79,18 @@ bool dp_unpack_pam_request(DBusMessage *msg, TALLOC_CTX *mem_ctx,
int ret;
struct pam_data pd;
uint32_t authtok_type;
- uint32_t authtok_length;
+ int authtok_length;
uint8_t *authtok_data;
uint32_t new_authtok_type;
- uint32_t new_authtok_length;
+ int new_authtok_length;
uint8_t *new_authtok_data;
+ int32_t pd_cmd;
+ int32_t pd_priv;
memset(&pd, 0, sizeof(pd));
db_ret = dbus_message_get_args(msg, dbus_error,
- DBUS_TYPE_INT32, &(pd.cmd),
+ DBUS_TYPE_INT32, &pd_cmd,
DBUS_TYPE_STRING, &(pd.user),
DBUS_TYPE_STRING, &(pd.domain),
DBUS_TYPE_STRING, &(pd.service),
@@ -97,7 +103,7 @@ bool dp_unpack_pam_request(DBusMessage *msg, TALLOC_CTX *mem_ctx,
DBUS_TYPE_UINT32, &new_authtok_type,
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
&new_authtok_data, &new_authtok_length,
- DBUS_TYPE_INT32, &(pd.priv),
+ DBUS_TYPE_INT32, &pd_priv,
DBUS_TYPE_UINT32, &(pd.cli_pid),
DBUS_TYPE_INVALID);
@@ -106,6 +112,9 @@ bool dp_unpack_pam_request(DBusMessage *msg, TALLOC_CTX *mem_ctx,
return false;
}
+ pd.cmd = pd_cmd;
+ pd.priv = pd_priv;
+
ret = copy_pam_data(mem_ctx, &pd, new_pd);
if (ret != EOK) {
DEBUG(1, ("copy_pam_data failed.\n"));
@@ -136,12 +145,15 @@ bool dp_pack_pam_response(DBusMessage *msg, struct pam_data *pd)
DBusMessageIter array_iter;
DBusMessageIter struct_iter;
DBusMessageIter data_iter;
+ uint32_t pam_status;
+ uint32_t resp_type;
dbus_message_iter_init_append(msg, &iter);
/* Append the PAM status */
+ pam_status = pd->pam_status;
dbret = dbus_message_iter_append_basic(&iter,
- DBUS_TYPE_UINT32, &(pd->pam_status));
+ DBUS_TYPE_UINT32, &pam_status);
if (!dbret) {
return false;
}
@@ -165,9 +177,10 @@ bool dp_pack_pam_response(DBusMessage *msg, struct pam_data *pd)
}
/* Add the response type */
+ resp_type = resp->type;
dbret = dbus_message_iter_append_basic(&struct_iter,
DBUS_TYPE_UINT32,
- &(resp->type));
+ &resp_type);
if (!dbret) {
return false;
}