summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap/ldap_child.c
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-03-01 16:41:12 -0500
committerSimo Sorce <ssorce@redhat.com>2010-03-03 10:39:52 -0500
commit6adf5b8a078f2b37f2d3d91cd060b891c2a7efaa (patch)
tree78f1d2796c090e17d6c7cff2976c83ad0691d307 /src/providers/ldap/ldap_child.c
parent8615b37ca00ea7d25a7b984a773dbd72a0025171 (diff)
downloadsssd-6adf5b8a078f2b37f2d3d91cd060b891c2a7efaa.tar.gz
sssd-6adf5b8a078f2b37f2d3d91cd060b891c2a7efaa.tar.xz
sssd-6adf5b8a078f2b37f2d3d91cd060b891c2a7efaa.zip
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.
Diffstat (limited to 'src/providers/ldap/ldap_child.c')
-rw-r--r--src/providers/ldap/ldap_child.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c
index 0d34be2ca..069fbcfe1 100644
--- a/src/providers/ldap/ldap_child.c
+++ b/src/providers/ldap/ldap_child.c
@@ -51,7 +51,7 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size,
DEBUG(7, ("total buffer size: %d\n", size));
/* realm_str size and length */
- COPY_UINT32_CHECK(&len, buf + p, p, size);
+ SAFEALIGN_COPY_UINT32_CHECK(&len, buf + p, size, &p);
DEBUG(7, ("realm_str size: %d\n", len));
if (len) {
@@ -63,7 +63,7 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size,
}
/* princ_str size and length */
- COPY_UINT32_CHECK(&len, buf + p, p, size);
+ SAFEALIGN_COPY_UINT32_CHECK(&len, buf + p, size, &p);
DEBUG(7, ("princ_str size: %d\n", len));
if (len) {
@@ -75,7 +75,7 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size,
}
/* keytab_name size and length */
- COPY_UINT32_CHECK(&len, buf + p, p, size);
+ SAFEALIGN_COPY_UINT32_CHECK(&len, buf + p, size, &p);
DEBUG(7, ("keytab_name size: %d\n", len));
if (len) {
@@ -92,19 +92,19 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size,
static int pack_buffer(struct response *r, int result, const char *msg)
{
int len;
- int p = 0;
+ size_t p = 0;
len = strlen(msg);
r->size = 2 * sizeof(uint32_t) + len;
/* result */
- COPY_UINT32_VALUE(&r->buf[p], result, p);
+ SAFEALIGN_SET_UINT32(&r->buf[p], result, &p);
/* message size */
- COPY_UINT32_VALUE(&r->buf[p], len, p);
+ SAFEALIGN_SET_UINT32(&r->buf[p], len, &p);
/* message itself */
- COPY_MEM(&r->buf[p], msg, p, len);
+ safealign_memcpy(&r->buf[p], msg, len, &p);
return EOK;
}