1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-01 21:18:10 +03:00

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 commit is contained in:
Stefan Metzmacher 2006-10-09 08:26:58 +00:00 committed by Gerald (Jerry) Carter
parent 93a0fe093b
commit a5ea82bb05

View File

@ -210,10 +210,15 @@ static int lldb_add_msg_attr(struct ldb_context *ldb,
} }
for (i=0;i<count;i++) { 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) { if (!el->values[i].data) {
errno = ENOMEM;
return -1; 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->values[i].length = bval[i]->bv_len;
el->num_values++; el->num_values++;
} }