summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-09-30 07:54:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:20:28 -0500
commitbf86ece6cb9ff38bd08fb39988d9dc7577ea3f99 (patch)
treeb88b731a7914780e341e0e2fcb70cc33314672ff /source4
parente8a005acfe15462b2f7e2aaa66a585d6da098a09 (diff)
downloadsamba-bf86ece6cb9ff38bd08fb39988d9dc7577ea3f99.tar.gz
samba-bf86ece6cb9ff38bd08fb39988d9dc7577ea3f99.tar.bz2
samba-bf86ece6cb9ff38bd08fb39988d9dc7577ea3f99.zip
r19009: ensure that data values from ldap libs are null terminated, to allow
ldb_msg_find_attr_as_string() to work correctly. Thanks to Jim Myers for spotting this! (This used to be commit b2076c1a7e4b70644b59689ce46952ef940be6b0)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index 9de67e5ad7..10563816b9 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -210,10 +210,15 @@ static int lldb_add_msg_attr(struct ldb_context *ldb,
}
for (i=0;i<count;i++) {
- el->values[i].data = talloc_memdup(el->values, bval[i]->bv_val, bval[i]->bv_len);
+ /* we have to ensure this is null terminated so that
+ ldb_msg_find_attr_as_string() can work */
+ el->values[i].data = talloc_size(el->values, bval[i]->bv_len+1);
if (!el->values[i].data) {
+ errno = ENOMEM;
return -1;
}
+ memcpy(el->values[i].data, bval[i]->bv_val, bval[i]->bv_len);
+ el->values[i].data[bval[i]->bv_len] = 0;
el->values[i].length = bval[i]->bv_len;
el->num_values++;
}