ldb bug fixes

Adrian Cochrane adrianc at catalyst.net.nz
Wed Dec 2 03:31:31 UTC 2015


Another update, realized that if I'm allocating empty arrays it's 
probably useful still to check it for null.

On Thu, Nov 26, 2015 at 4:45 PM, Adrian Cochrane 
<adrianc at catalyst.net.nz> wrote:
> Updated patch per Andrew's comments.
> 
> On Wed, Nov 25, 2015 at 10:56 AM, Andrew Bartlett 
> <abartlet at samba.org> wrote:
>> On Mon, 2015-11-23 at 14:35 +1300, Adrian Cochrane wrote:
>>>  It turns out that wouldn't be an easier fix because
>>>  /lib/talloc/talloc_guide.txt specifically states:
>>>  >   talloc_realloc(context, ptr, type, 0) ==> talloc_free(ptr);
>>> 
>>>  However I did take your advice and incorporated it into this 
>>> updated
>>>  patch.
>> 
>> I think this, but with an error check on
>> msg->elements = talloc_array(msg, struct ldb_message_element, 0);
>> 
>> would be the correct solution.
>> 
>> LDB entries with zero attributes are vanishingly rare, but asking for
>> zero attributes is common, as is asking only for attributes that 
>> don't
>> exist.  We may post-process the ldb_message to add a generated
>> attribute later, and we should have a zero-length array to do that 
>> on.
>> 
>> This also follows the principle of least supprise from the current
>> code, which always returned an array the same length as the database
>> object (ie, always non-NULL, even with num_elements == 0)
>> 
>> Thanks,
>> 
>> Andrew Bartlett
>> 
>> --
>> Andrew Bartlett
>> https://samba.org/~abartlet/
>> Authentication Developer, Samba Team         https://samba.org
>> Samba Development and Support, Catalyst IT
>> https://catalyst.net.nz/services/samba
>> 
>> 
>> 
>> 
>> 
>> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ldb-Fix-bug-triggered-by-having-an-empty-message-in-.patch
Type: text/x-patch
Size: 4039 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20151202/f1dc934e/0001-ldb-Fix-bug-triggered-by-having-an-empty-message-in-.bin>


More information about the samba-technical mailing list