diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-10-09 08:26:58 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:15:21 -0500 |
commit | c9b797b3baadf2ab1d385fc7c83d1770309e5eb7 (patch) | |
tree | 4fb738134a666e4581f4eb6d2f089ebf75810f95 /source3/lib/ldb | |
parent | 85281ec52619180ebde44c6a48616292e341be3b (diff) | |
download | samba-c9b797b3baadf2ab1d385fc7c83d1770309e5eb7.tar.gz samba-c9b797b3baadf2ab1d385fc7c83d1770309e5eb7.tar.bz2 samba-c9b797b3baadf2ab1d385fc7c83d1770309e5eb7.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
(This used to be commit a5ea82bb05fb9d5c1842f9a105f6a10e39141c89)
Diffstat (limited to 'source3/lib/ldb')
-rw-r--r-- | source3/lib/ldb/ldb_ldap/ldb_ldap.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/source3/lib/ldb/ldb_ldap/ldb_ldap.c b/source3/lib/ldb/ldb_ldap/ldb_ldap.c index 9de67e5ad7..10563816b9 100644 --- a/source3/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source3/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++; } |