ldb: Fix bug triggered by having an empty message in database during search.
authorAdrian Cochrane <adrianc@catalyst.net.nz>
Wed, 18 Nov 2015 02:25:20 +0000 (15:25 +1300)
committerGarming Sam <garming@samba.org>
Fri, 4 Dec 2015 05:08:29 +0000 (06:08 +0100)
commit99b2fd4f5be9dca1ef66c8a8096e3e75fee84a7f
treead1975d0feae75dd15ee8eac90b4d19886985dd9
parentc118fbc680f84622c12997cf347f3194d532ddbc
ldb: Fix bug triggered by having an empty message in database during search.

Previously if the message had 0 elements, Talloc would reallocate the projected
array to NULL, fooling LDB into thinking that it failed to reallocate. This fix
corrects LDB to be able to handle the case where the message has no attributes
in common with the filter.

Also the realloc call resized the array to the number of elements in the message,
not the number of elements in common with the filter -- it essentially did nothing.

Unlike talloc_realloc, talloc_array always returns a non-null pointer. This would
help protect against possible errors.

Signed-off-by: Adrian Cochrane <adrianc@catalyst.net.nz>
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/ldb_tdb/ldb_search.c
lib/ldb/tests/python/api.py