From 6adf5b8a078f2b37f2d3d91cd060b891c2a7efaa Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 1 Mar 2010 16:41:12 -0500 Subject: Improve safe alignment buffer handling macros Make the counter optional so that alignment safe macros can be used also where there is no counter to update. Change arguments names so that they are not deceiving (ptr normlly identify a pointer) Turn the memcpy substitute into an inline function so that passing a pointer to rp and checking for it doesn't make the compiler spit lots of warnings. --- src/providers/ldap/sdap_child_helpers.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/providers/ldap/sdap_child_helpers.c') diff --git a/src/providers/ldap/sdap_child_helpers.c b/src/providers/ldap/sdap_child_helpers.c index 0a95c8a0..273fc678 100644 --- a/src/providers/ldap/sdap_child_helpers.c +++ b/src/providers/ldap/sdap_child_helpers.c @@ -166,26 +166,26 @@ static errno_t create_tgt_req_send_buffer(TALLOC_CTX *mem_ctx, /* realm */ if (realm_str) { - COPY_UINT32_VALUE(&buf->data[rp], strlen(realm_str), rp); - COPY_MEM(&buf->data[rp], realm_str, rp, strlen(realm_str)); + SAFEALIGN_SET_UINT32(&buf->data[rp], strlen(realm_str), &rp); + safealign_memcpy(&buf->data[rp], realm_str, strlen(realm_str), &rp); } else { - COPY_UINT32_VALUE(&buf->data[rp], 0, rp); + SAFEALIGN_SET_UINT32(&buf->data[rp], 0, &rp); } /* principal */ if (princ_str) { - COPY_UINT32_VALUE(&buf->data[rp], strlen(princ_str), rp); - COPY_MEM(&buf->data[rp], princ_str, rp, strlen(princ_str)); + SAFEALIGN_SET_UINT32(&buf->data[rp], strlen(princ_str), &rp); + safealign_memcpy(&buf->data[rp], princ_str, strlen(princ_str), &rp); } else { - COPY_UINT32_VALUE(&buf->data[rp], 0, rp); + SAFEALIGN_SET_UINT32(&buf->data[rp], 0, &rp); } /* keytab */ if (keytab_name) { - COPY_UINT32_VALUE(&buf->data[rp], strlen(keytab_name), rp); - COPY_MEM(&buf->data[rp], keytab_name, rp, strlen(realm_str)); + SAFEALIGN_SET_UINT32(&buf->data[rp], strlen(keytab_name), &rp); + safealign_memcpy(&buf->data[rp], keytab_name, strlen(realm_str), &rp); } else { - COPY_UINT32_VALUE(&buf->data[rp], 0, rp); + SAFEALIGN_SET_UINT32(&buf->data[rp], 0, &rp); } *io_buf = buf; @@ -202,10 +202,10 @@ static int parse_child_response(TALLOC_CTX *mem_ctx, char *ccn; /* operation result code */ - COPY_UINT32_CHECK(&res, buf + p, p, size); + SAFEALIGN_COPY_UINT32_CHECK(&res, buf + p, size, &p); /* ccache name size */ - COPY_UINT32_CHECK(&len, buf + p, p, size); + SAFEALIGN_COPY_UINT32_CHECK(&len, buf + p, size, &p); if ((p + len ) > size) return EINVAL; -- cgit