summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2010-03-23 16:35:49 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-03-25 16:02:27 -0400
commit80c8a4f94d54b23bce206fdd75ff2648977ce271 (patch)
tree7a03b98f665e4ebf7005c580fd9873200f023fad /src/util
parentf94abf5319d8f74cacae0a98d3925d18eb6839eb (diff)
downloadsssd-80c8a4f94d54b23bce206fdd75ff2648977ce271.tar.gz
sssd-80c8a4f94d54b23bce206fdd75ff2648977ce271.tar.xz
sssd-80c8a4f94d54b23bce206fdd75ff2648977ce271.zip
Allow arbitrary-length PAM messages
The PAM standard allows for messages of any length to be returned to the client. We were discarding all messages of length greater than 255. This patch dynamically allocates the message buffers so we can pass the complete message. This resolves https://fedorahosted.org/sssd/ticket/432
Diffstat (limited to 'src/util')
-rw-r--r--src/util/user_info_msg.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/util/user_info_msg.c b/src/util/user_info_msg.c
index 547e3bb74..505b03d91 100644
--- a/src/util/user_info_msg.c
+++ b/src/util/user_info_msg.c
@@ -33,6 +33,7 @@ errno_t pack_user_info_chpass_error(TALLOC_CTX *mem_ctx,
uint32_t resp_type = SSS_PAM_USER_INFO_CHPASS_ERROR;
size_t err_len;
uint8_t *resp;
+ size_t p;
err_len = strlen(user_error_message);
*resp_len = 2 * sizeof(uint32_t) + err_len;
@@ -42,9 +43,13 @@ errno_t pack_user_info_chpass_error(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
- memcpy(resp, &resp_type, sizeof(uint32_t));
- memcpy(resp + sizeof(uint32_t), &err_len, sizeof(uint32_t));
- memcpy(resp + 2 * sizeof(uint32_t), user_error_message, err_len);
+ p = 0;
+ SAFEALIGN_SET_UINT32(&resp[p], resp_type, &p);
+ SAFEALIGN_SET_UINT32(&resp[p], err_len, &p);
+ safealign_memcpy(&resp[p], user_error_message, err_len, &p);
+ if (p != *resp_len) {
+ DEBUG(0, ("Size mismatch\n"));
+ }
*_resp = resp;
return EOK;