From a4cbb8f8cd490b70a61a0522046e07326bf11233 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Fri, 5 Nov 2010 14:57:13 +0100 Subject: [PATCH 1/2] Avoid long long in messages to PAM client use int64_t --- src/responder/pam/pamsrv_cmd.c | 14 +++++++------- src/sss_client/pam_sss.c | 12 ++++++------ src/sss_client/sss_cli.h | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c index 7bfd0f2..1ba6f17 100644 --- a/src/responder/pam/pamsrv_cmd.c +++ b/src/responder/pam/pamsrv_cmd.c @@ -507,21 +507,21 @@ static void pam_cache_auth_done(struct pam_auth_req *preq, int ret, uint32_t resp_type; size_t resp_len; uint8_t *resp; - long long dummy; + int64_t dummy; switch (ret) { case EOK: preq->pd->pam_status = PAM_SUCCESS; resp_type = SSS_PAM_USER_INFO_OFFLINE_AUTH; - resp_len = sizeof(uint32_t) + sizeof(long long); + resp_len = sizeof(uint32_t) + sizeof(int64_t); resp = talloc_size(preq->pd, resp_len); if (resp == NULL) { DEBUG(1, ("talloc_size failed, cannot prepare user info.\n")); } else { memcpy(resp, &resp_type, sizeof(uint32_t)); - dummy = (long long) expire_date; - memcpy(resp+sizeof(uint32_t), &dummy, sizeof(long long)); + dummy = (int64_t) expire_date; + memcpy(resp+sizeof(uint32_t), &dummy, sizeof(int64_t)); ret = pam_add_response(preq->pd, SSS_PAM_USER_INFO, resp_len, (const uint8_t *) resp); if (ret != EOK) { @@ -539,14 +539,14 @@ static void pam_cache_auth_done(struct pam_auth_req *preq, int ret, preq->pd->pam_status = PAM_PERM_DENIED; if (delayed_until >= 0) { resp_type = SSS_PAM_USER_INFO_OFFLINE_AUTH_DELAYED; - resp_len = sizeof(uint32_t) + sizeof(long long); + resp_len = sizeof(uint32_t) + sizeof(int64_t); resp = talloc_size(preq->pd, resp_len); if (resp == NULL) { DEBUG(1, ("talloc_size failed, cannot prepare user info.\n")); } else { memcpy(resp, &resp_type, sizeof(uint32_t)); - dummy = (long long) delayed_until; - memcpy(resp+sizeof(uint32_t), &dummy, sizeof(long long)); + dummy = (int64_t) delayed_until; + memcpy(resp+sizeof(uint32_t), &dummy, sizeof(int64_t)); ret = pam_add_response(preq->pd, SSS_PAM_USER_INFO, resp_len, (const uint8_t *) resp); if (ret != EOK) { diff --git a/src/sss_client/pam_sss.c b/src/sss_client/pam_sss.c index 644073f..f7876c2 100644 --- a/src/sss_client/pam_sss.c +++ b/src/sss_client/pam_sss.c @@ -567,19 +567,19 @@ static int user_info_offline_auth(pam_handle_t *pamh, size_t buflen, uint8_t *buf) { int ret; - long long expire_date; + int64_t expire_date; struct tm tm; char expire_str[128]; char user_msg[256]; expire_str[0] = '\0'; - if (buflen != sizeof(uint32_t) + sizeof(long long)) { + if (buflen != sizeof(uint32_t) + sizeof(int64_t)) { D(("User info response data has the wrong size")); return PAM_BUF_ERR; } - memcpy(&expire_date, buf + sizeof(uint32_t), sizeof(long long)); + memcpy(&expire_date, buf + sizeof(uint32_t), sizeof(int64_t)); if (expire_date > 0) { if (localtime_r((time_t *) &expire_date, &tm) != NULL) { @@ -690,19 +690,19 @@ static int user_info_offline_auth_delayed(pam_handle_t *pamh, size_t buflen, uint8_t *buf) { int ret; - long long delayed_until; + int64_t delayed_until; struct tm tm; char delay_str[128]; char user_msg[256]; delay_str[0] = '\0'; - if (buflen != sizeof(uint32_t) + sizeof(long long)) { + if (buflen != sizeof(uint32_t) + sizeof(int64_t)) { D(("User info response data has the wrong size")); return PAM_BUF_ERR; } - memcpy(&delayed_until, buf + sizeof(uint32_t), sizeof(long long)); + memcpy(&delayed_until, buf + sizeof(uint32_t), sizeof(int64_t)); if (delayed_until <= 0) { D(("User info response data has an invalid value")); diff --git a/src/sss_client/sss_cli.h b/src/sss_client/sss_cli.h index fcea8e6..f8ccb4f 100644 --- a/src/sss_client/sss_cli.h +++ b/src/sss_client/sss_cli.h @@ -364,7 +364,7 @@ enum user_info_type { * @param Time when the cached * password will expire in seconds * since the UNIX Epoch as returned - * by time(2) as long long. A value + * by time(2) as int64_t. A value * of zero indicates that the * cached password will never * expire. */ @@ -375,8 +375,8 @@ enum user_info_type { * @param Time when an * authentication is allowed again * in seconds since the UNIX Epoch - * as returned by time(2) as long - * long. */ + * as returned by time(2) as + * int64_t. */ SSS_PAM_USER_INFO_OFFLINE_CHPASS, /**< * Tell the user that it is not * possible to change the password while * the system is offline. This message -- 1.7.3.2