summaryrefslogtreecommitdiffstats
path: root/server/providers/krb5/krb5_auth.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-01-25 23:59:03 +0100
committerStephen Gallagher <sgallagh@redhat.com>2010-02-10 08:46:49 -0500
commit43e56fc55593f3f7d14f73017d3b362839d167e2 (patch)
treec5384b1ca3494accc51255468358095554a8124c /server/providers/krb5/krb5_auth.c
parent365321d07f67683993bccdc33a3d832e64bdef1c (diff)
downloadsssd-43e56fc55593f3f7d14f73017d3b362839d167e2.tar.gz
sssd-43e56fc55593f3f7d14f73017d3b362839d167e2.tar.xz
sssd-43e56fc55593f3f7d14f73017d3b362839d167e2.zip
Fix other memory alignment issues
Similar to George McCollister's patch to the pam code, this patch fixes other places in the code where we forced data into 32-bit alignment. Fixes: #390
Diffstat (limited to 'server/providers/krb5/krb5_auth.c')
-rw-r--r--server/providers/krb5/krb5_auth.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/server/providers/krb5/krb5_auth.c b/server/providers/krb5/krb5_auth.c
index c013ea89e..fd0a06392 100644
--- a/server/providers/krb5/krb5_auth.c
+++ b/server/providers/krb5/krb5_auth.c
@@ -301,6 +301,7 @@ errno_t create_send_buffer(struct krb5child_req *kr, struct io_buffer **io_buf)
size_t rp;
const char *keytab;
uint32_t validate;
+ uint32_t c = 0;
keytab = dp_opt_get_cstring(kr->krb5_ctx->opts, KRB5_KEYTAB);
if (keytab == NULL) {
@@ -331,47 +332,50 @@ errno_t create_send_buffer(struct krb5child_req *kr, struct io_buffer **io_buf)
}
rp = 0;
- ((uint32_t *)(&buf->data[rp]))[0] = kr->pd->cmd;
+ memcpy(&buf->data[rp], &kr->pd->cmd, sizeof(uint32_t));
rp += sizeof(uint32_t);
- ((uint32_t *)(&buf->data[rp]))[0] = kr->pd->pw_uid;
+ memcpy(&buf->data[rp], &kr->pd->pw_uid, sizeof(uint32_t));
rp += sizeof(uint32_t);
- ((uint32_t *)(&buf->data[rp]))[0] = kr->pd->gr_gid;
+ memcpy(&buf->data[rp], &kr->pd->gr_gid, sizeof(uint32_t));
rp += sizeof(uint32_t);
- ((uint32_t *)(&buf->data[rp]))[0] = validate;
+ memcpy(&buf->data[rp], &validate, sizeof(uint32_t));
rp += sizeof(uint32_t);
- ((uint32_t *)(&buf->data[rp]))[0] = kr->is_offline;
+ memcpy(&buf->data[rp], &kr->is_offline, sizeof(uint32_t));
rp += sizeof(uint32_t);
- ((uint32_t *)(&buf->data[rp]))[0] = (uint32_t) strlen(kr->pd->upn);
+ c = (uint32_t) strlen(kr->pd->upn);
+ memcpy(&buf->data[rp], &c, sizeof(uint32_t));
rp += sizeof(uint32_t);
- memcpy(&buf->data[rp], kr->pd->upn, strlen(kr->pd->upn));
- rp += strlen(kr->pd->upn);
+ memcpy(&buf->data[rp], kr->pd->upn, c);
+ rp += c;
- ((uint32_t *)(&buf->data[rp]))[0] = (uint32_t) strlen(kr->ccname);
+ c = (uint32_t) strlen(kr->ccname);
+ memcpy(&buf->data[rp], &c, sizeof(uint32_t));
rp += sizeof(uint32_t);
- memcpy(&buf->data[rp], kr->ccname, strlen(kr->ccname));
+ memcpy(&buf->data[rp], kr->ccname, c);
rp += strlen(kr->ccname);
- ((uint32_t *)(&buf->data[rp]))[0] = (uint32_t) strlen(keytab);
+ c = (uint32_t) strlen(keytab);
+ memcpy(&buf->data[rp], &c, sizeof(uint32_t));
rp += sizeof(uint32_t);
- memcpy(&buf->data[rp], keytab, strlen(keytab));
+ memcpy(&buf->data[rp], keytab, c);
rp += strlen(keytab);
- ((uint32_t *)(&buf->data[rp]))[0] = kr->pd->authtok_size;
+ memcpy(&buf->data[rp], &kr->pd->authtok_size, sizeof(uint32_t));
rp += sizeof(uint32_t);
memcpy(&buf->data[rp], kr->pd->authtok, kr->pd->authtok_size);
rp += kr->pd->authtok_size;
if (kr->pd->cmd == SSS_PAM_CHAUTHTOK) {
- ((uint32_t *)(&buf->data[rp]))[0] = kr->pd->newauthtok_size;
+ memcpy(&buf->data[rp], &kr->pd->newauthtok_size, sizeof(uint32_t));
rp += sizeof(uint32_t);
memcpy(&buf->data[rp], kr->pd->newauthtok, kr->pd->newauthtok_size);