ldb bug fixes

Adrian Cochrane adrianc at catalyst.net.nz
Fri Dec 4 02:54:10 UTC 2015


Now I've got two working patches to propose to Samba, the first is the 
one which fixes LDB to be able to handle empty messages in the 
database. The second depends on it and would make that sort of issue 
more obvious in the future. Please review

On Fri, Dec 4, 2015 at 10:03 AM, Adrian Cochrane 
<adrianc at catalyst.net.nz> wrote:
> It seems the patch for fixing error propagation is failing some 
> tests. Please hold on that one.
> 
> I'm still happy with the patch for fixing handling of empty LDB 
> messages (attached for clarity).
> 
> On Thu, Dec 3, 2015 at 2:29 PM, Adrian Cochrane 
> <adrianc at catalyst.net.nz> wrote:
>> Since the symptoms of the big I fixed in more previous patch were 
>> incorrect, here's a patch which corrects the error propagation in 
>> LDB.
>> 
>> On Wed, Dec 2, 2015 at 4:31 PM, Adrian Cochrane 
>> <adrianc at catalyst.net.nz> wrote:
>>> 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: 0002-Fix-propagation-of-LDB-errors-through-TDB.patch
Type: text/x-patch
Size: 13379 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20151204/e31f2168/0002-Fix-propagation-of-LDB-errors-through-TDB.bin>
-------------- 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: 4043 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20151204/e31f2168/0001-ldb-Fix-bug-triggered-by-having-an-empty-message-in-.bin>


More information about the samba-technical mailing list