diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2010-01-25 23:59:03 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-02-10 08:46:49 -0500 |
commit | 43e56fc55593f3f7d14f73017d3b362839d167e2 (patch) | |
tree | c5384b1ca3494accc51255468358095554a8124c /server/providers/krb5/krb5_child.c | |
parent | 365321d07f67683993bccdc33a3d832e64bdef1c (diff) | |
download | sssd-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_child.c')
-rw-r--r-- | server/providers/krb5/krb5_child.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/server/providers/krb5/krb5_child.c b/server/providers/krb5/krb5_child.c index b73032605..d8f733b70 100644 --- a/server/providers/krb5/krb5_child.c +++ b/server/providers/krb5/krb5_child.c @@ -260,6 +260,7 @@ static errno_t pack_response_packet(struct response *resp, int status, int type, { int len; int p=0; + int32_t c; len = strlen(data)+1; if ((3*sizeof(int32_t) + len +1) > resp->max_size) { @@ -267,13 +268,16 @@ static errno_t pack_response_packet(struct response *resp, int status, int type, return ENOMEM; } - ((int32_t *)(&resp->buf[p]))[0] = status; + c = status; + memcpy(&resp->buf[p], &c, sizeof(int32_t)); p += sizeof(int32_t); - ((int32_t *)(&resp->buf[p]))[0] = type; + c = type; + memcpy(&resp->buf[p], &c, sizeof(int32_t)); p += sizeof(int32_t); - ((int32_t *)(&resp->buf[p]))[0] = len; + c = len; + memcpy(&resp->buf[p], &c, sizeof(int32_t)); p += sizeof(int32_t); memcpy(&resp->buf[p], data, len); @@ -695,28 +699,27 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size, struct pam_data *pd, uint32_t len; if ((p + sizeof(uint32_t)) > size) return EINVAL; - pd->cmd = *((uint32_t *)(buf + p)); + memcpy(&pd->cmd, buf + p, sizeof(uint32_t)); p += sizeof(uint32_t); if ((p + sizeof(uint32_t)) > size) return EINVAL; - pd->pw_uid = *((uint32_t *)(buf + p)); + memcpy(&pd->pw_uid, buf + p, sizeof(uint32_t)); p += sizeof(uint32_t); if ((p + sizeof(uint32_t)) > size) return EINVAL; - pd->gr_gid = *((uint32_t *)(buf + p)); + memcpy(&pd->gr_gid, buf + p, sizeof(uint32_t)); p += sizeof(uint32_t); if ((p + sizeof(uint32_t)) > size) return EINVAL; - *validate = *((uint32_t *)(buf + p)); + memcpy(validate, buf + p, sizeof(uint32_t)); p += sizeof(uint32_t); if ((p + sizeof(uint32_t)) > size) return EINVAL; - len = *((uint32_t *)(buf + p)); - *offline = len; + memcpy(offline, buf + p, sizeof(uint32_t)); p += sizeof(uint32_t); if ((p + sizeof(uint32_t)) > size) return EINVAL; - len = *((uint32_t *)(buf + p)); + memcpy(&len, buf + p, sizeof(uint32_t)); p += sizeof(uint32_t); if ((p + len ) > size) return EINVAL; @@ -725,7 +728,7 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size, struct pam_data *pd, p += len; if ((p + sizeof(uint32_t)) > size) return EINVAL; - len = *((uint32_t *)(buf + p)); + memcpy(&len, buf + p, sizeof(uint32_t)); p += sizeof(uint32_t); if ((p + len ) > size) return EINVAL; @@ -734,7 +737,7 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size, struct pam_data *pd, p += len; if ((p + sizeof(uint32_t)) > size) return EINVAL; - len = *((uint32_t *)(buf + p)); + memcpy(&len, buf + p, sizeof(uint32_t)); p += sizeof(uint32_t); if ((p + len ) > size) return EINVAL; @@ -743,7 +746,7 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size, struct pam_data *pd, p += len; if ((p + sizeof(uint32_t)) > size) return EINVAL; - len = *((uint32_t *)(buf + p)); + memcpy(&len, buf + p, sizeof(uint32_t)); p += sizeof(uint32_t); if ((p + len) > size) return EINVAL; @@ -754,7 +757,7 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size, struct pam_data *pd, if (pd->cmd == SSS_PAM_CHAUTHTOK) { if ((p + sizeof(uint32_t)) > size) return EINVAL; - len = *((uint32_t *)(buf + p)); + memcpy(&len, buf + p, sizeof(uint32_t)); p += sizeof(uint32_t); if ((p + len) > size) return EINVAL; |