summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-08-16 11:00:41 +1000
committerAndrew Tridgell <tridge@samba.org>2010-08-17 08:44:28 +1000
commit1cc471d69fc6ff5dc835462b712645415f8feca4 (patch)
tree37be411e1c30083d4b94fe96b30219e551998a68 /source4/lib/ldb/ldb_tdb
parent68e86969fae55584f12191f09ac0442d09872030 (diff)
downloadsamba-1cc471d69fc6ff5dc835462b712645415f8feca4.tar.gz
samba-1cc471d69fc6ff5dc835462b712645415f8feca4.tar.bz2
samba-1cc471d69fc6ff5dc835462b712645415f8feca4.zip
s4-ldb: add some comments explaining the ltdb_index_idxptr() function
this function copes with alignment sensitive CPUs Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 828dca1f2c..4f5979877b 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -95,6 +95,11 @@ static int ltdb_dn_list_find_str(struct dn_list *list, const char *dn)
return ltdb_dn_list_find_val(list, &v);
}
+/*
+ this is effectively a cast function, but with lots of paranoia
+ checks and also copes with CPUs that are fussy about pointer
+ alignment
+ */
static struct dn_list *ltdb_index_idxptr(struct ldb_module *module, TDB_DATA rec, bool check_parent)
{
struct dn_list *list;
@@ -103,6 +108,9 @@ static struct dn_list *ltdb_index_idxptr(struct ldb_module *module, TDB_DATA rec
"Bad data size for idxptr %u", (unsigned)rec.dsize);
return NULL;
}
+ /* note that we can't just use a cast here, as rec.dptr may
+ not be aligned sufficiently for a pointer. A cast would cause
+ platforms like some ARM CPUs to crash */
memcpy(&list, rec.dptr, sizeof(void *));
list = talloc_get_type(list, struct dn_list);
if (list == NULL) {