diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2010-02-10 13:01:33 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-02-18 13:48:44 -0500 |
commit | 29e9f5e711a03135944e30ad241c8182dacc6049 (patch) | |
tree | 0da07910b6618ced8b16d0011ad023687efed7cc /server/providers/ldap/sdap_child_helpers.c | |
parent | 2c5bf74c71443f1680fef4fc0daa4a4c9dd10ad8 (diff) | |
download | sssd-29e9f5e711a03135944e30ad241c8182dacc6049.tar.gz sssd-29e9f5e711a03135944e30ad241c8182dacc6049.tar.bz2 sssd-29e9f5e711a03135944e30ad241c8182dacc6049.zip |
Use macros to hide memcpy calls
The memcpy calls introduced in the memalign patches are ugly. This patch
hides them behind a set of macros.
Diffstat (limited to 'server/providers/ldap/sdap_child_helpers.c')
-rw-r--r-- | server/providers/ldap/sdap_child_helpers.c | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/server/providers/ldap/sdap_child_helpers.c b/server/providers/ldap/sdap_child_helpers.c index 7f743d7f..0a95c8a0 100644 --- a/server/providers/ldap/sdap_child_helpers.c +++ b/server/providers/ldap/sdap_child_helpers.c @@ -135,7 +135,6 @@ static errno_t create_tgt_req_send_buffer(TALLOC_CTX *mem_ctx, { struct io_buffer *buf; size_t rp; - int len; buf = talloc(mem_ctx, struct io_buffer); if (buf == NULL) { @@ -167,41 +166,26 @@ static errno_t create_tgt_req_send_buffer(TALLOC_CTX *mem_ctx, /* realm */ if (realm_str) { - len = strlen(realm_str); - memcpy(&buf->data[rp], &len, sizeof(uint32_t)); - rp += sizeof(uint32_t); - memcpy(&buf->data[rp], realm_str, len); - rp += len; + COPY_UINT32_VALUE(&buf->data[rp], strlen(realm_str), rp); + COPY_MEM(&buf->data[rp], realm_str, rp, strlen(realm_str)); } else { - len = 0; - memcpy(&buf->data[rp], &len, sizeof(uint32_t)); - rp += sizeof(uint32_t); + COPY_UINT32_VALUE(&buf->data[rp], 0, rp); } /* principal */ if (princ_str) { - len = strlen(princ_str); - memcpy(&buf->data[rp], &len, sizeof(uint32_t)); - rp += sizeof(uint32_t); - memcpy(&buf->data[rp], princ_str, len); - rp += len; + COPY_UINT32_VALUE(&buf->data[rp], strlen(princ_str), rp); + COPY_MEM(&buf->data[rp], princ_str, rp, strlen(princ_str)); } else { - len = 0; - memcpy(&buf->data[rp], &len, sizeof(uint32_t)); - rp += sizeof(uint32_t); + COPY_UINT32_VALUE(&buf->data[rp], 0, rp); } /* keytab */ if (keytab_name) { - len = strlen(keytab_name); - memcpy(&buf->data[rp], &len, sizeof(uint32_t)); - rp += sizeof(uint32_t); - memcpy(&buf->data[rp], keytab_name, len); - rp += len; + COPY_UINT32_VALUE(&buf->data[rp], strlen(keytab_name), rp); + COPY_MEM(&buf->data[rp], keytab_name, rp, strlen(realm_str)); } else { - len = 0; - memcpy(&buf->data[rp], &len, sizeof(uint32_t)); - rp += sizeof(uint32_t); + COPY_UINT32_VALUE(&buf->data[rp], 0, rp); } *io_buf = buf; @@ -218,14 +202,10 @@ static int parse_child_response(TALLOC_CTX *mem_ctx, char *ccn; /* operation result code */ - if ((p + sizeof(uint32_t)) > size) return EINVAL; - memcpy(&res, buf + p, sizeof(uint32_t)); - p += sizeof(uint32_t); + COPY_UINT32_CHECK(&res, buf + p, p, size); /* ccache name size */ - if ((p + sizeof(uint32_t)) > size) return EINVAL; - memcpy(&len, buf + p, sizeof(uint32_t)); - p += sizeof(uint32_t); + COPY_UINT32_CHECK(&len, buf + p, p, size); if ((p + len ) > size) return EINVAL; |