[PATCH] lib/ldb minor fixes

Kamen Mazdrashki kamenim at samba.org
Mon Nov 10 21:25:09 MST 2014


Hi Andrew,

Actually there is a bug with the last patche indeed
The assertion 'if (a == NULL || a->name == NULL)' is too strong and I stop
processing for default ldb attribute definition (which is with name == NULL)

I have changed it to 'if (a == NULL)' and now everything is fine

Cheers,
Kamen


On Tue, Nov 11, 2014 at 3:45 AM, Kamen Mazdrashki <kamenim at samba.org> wrote:

> Hi Andrew,
>
> On Tue, Nov 11, 2014 at 3:32 AM, Andrew Bartlett <abartlet at samba.org>
> wrote:
>
>> G'Day Kamen,
>>
>> I'll push the rest of these shortly, but the last patch I'm not
>> comfortable with.  The code should be written such that this cannot
>> fail, and we should be able to print out the structure as LDIF even if
>> we don't fully understand it - otherwise debugging is going to get
>> really hard.
>>
>> What was the situation you hit this on?
>>
>> Pretty rookie actually - I have created message elements like
>   m = Message()
>   m[attr] = MessageElement(value)
> and it segfault because there is no name for the attribute.
> First it is going to segfault because of this:
>
> https://github.com/kamenim/samba/commit/f69a5f6618f64d6c6b584d90bfe1d61a62970deb
> and then in 'ldb_ldif_write_trace' because now '
> ldb_schema_attribute_by_name' doesn't segfault
> but fail gracefully.
>
> Cheers,
> Kamen
>
>
>
>> Thanks,
>>
>> Andrew Bartlett
>>
>> On Tue, 2014-11-11 at 03:20 +0100, Kamen Mazdrashki wrote:
>> > From: Kamen Mazdrashki <kamenim at samba.org>
>> > Date: Tue, 11 Nov 2014 02:57:50 +0100
>> > Subject: [PATCH 5/5] lib-ldb_ldif: Stop processing if we can't resolve
>> >  ldb_message element name
>> >
>> > This also prevent a segfault when using Python binding
>> >
>> > Signed-off-by: Kamen Mazdrashki <kamenim at samba.org>
>> > ---
>> >  lib/ldb/common/ldb_ldif.c | 7 +++++++
>> >  1 file changed, 7 insertions(+)
>> >
>> > diff --git a/lib/ldb/common/ldb_ldif.c b/lib/ldb/common/ldb_ldif.c
>> > index a2e4488..eb8179a 100644
>> > --- a/lib/ldb/common/ldb_ldif.c
>> > +++ b/lib/ldb/common/ldb_ldif.c
>> > @@ -313,6 +313,13 @@ static int ldb_ldif_write_trace(struct
>> > ldb_context *ldb,
>> >                 const struct ldb_schema_attribute *a;
>> >
>> >                 a = ldb_schema_attribute_by_name(ldb,
>> > msg->elements[i].name);
>> > +               if (a == NULL || a->name == NULL) {
>> > +                       ldb_debug(ldb, LDB_DEBUG_ERROR, "Error:
>> > ldb_schema_attribute_by_name() "
>> > +                                       "failed for Message element at
>> > %d with name %s.",
>> > +                                       i, msg->elements[i].name);
>> > +                       talloc_free(mem_ctx);
>> > +                       return -1;
>> > +               }
>> >
>> >                 if (ldif->changetype == LDB_CHANGETYPE_MODIFY) {
>> >                         switch (msg->elements[i].flags &
>> > LDB_FLAG_MOD_MASK) {
>>
>> --
>> Andrew Bartlett
>> http://samba.org/~abartlet/
>> Authentication Developer, Samba Team  http://samba.org
>> Samba Developer, Catalyst IT
>> http://catalyst.net.nz/services/samba
>>
>>
>>
>>
>>
>


More information about the samba-technical mailing list