1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

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)
This commit is contained in:
Andrew Tridgell 2006-09-30 07:54:20 +00:00 committed by Gerald (Jerry) Carter
parent e8a005acfe
commit bf86ece6cb

View File

@ -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++;
}