summaryrefslogtreecommitdiffstats
path: root/source/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-10-09 08:26:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:15:21 -0500
commita5ea82bb05fb9d5c1842f9a105f6a10e39141c89 (patch)
tree19eb3a369d8ec06b9f47d12aa57a5369516f4ca5 /source/lib
parent93a0fe093b4614a18e99d0c3a71c5c8af2e57e4f (diff)
downloadsamba-a5ea82bb05fb9d5c1842f9a105f6a10e39141c89.tar.gz
samba-a5ea82bb05fb9d5c1842f9a105f6a10e39141c89.tar.xz
samba-a5ea82bb05fb9d5c1842f9a105f6a10e39141c89.zip
r19192: merge from samba4:
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! metze
Diffstat (limited to 'source/lib')
-rw-r--r--source/lib/ldb/ldb_ldap/ldb_ldap.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/lib/ldb/ldb_ldap/ldb_ldap.c b/source/lib/ldb/ldb_ldap/ldb_ldap.c
index 9de67e5ad7f..10563816b97 100644
--- a/source/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source/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++;
}