[PATCH] lib/ldb minor fixes

Andrew Bartlett abartlet at samba.org
Mon Nov 10 19:32:58 MST 2014


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?

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