From 1d468467e623fb1c2010ddfa83d4f390d6c6b527 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Mon, 10 Nov 2008 14:24:29 +0000 Subject: [PATCH] Don't crash on empty groups (ITS#5800) --- contrib/slapd-modules/nssov/group.c | 33 +++++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/contrib/slapd-modules/nssov/group.c b/contrib/slapd-modules/nssov/group.c index 4cbdf7b4af..4c13acedba 100644 --- a/contrib/slapd-modules/nssov/group.c +++ b/contrib/slapd-modules/nssov/group.c @@ -191,26 +191,31 @@ static int write_group(nssov_group_cbp *cbp,Entry *entry) i += a->a_numvals; if ( b ) i += b->a_numvals; - if ( i ) + if ( i ) { members = cbp->op->o_tmpalloc( (i+1) * sizeof(struct berval), cbp->op->o_tmpmemctx ); - if ( a ) { - for (i=0; ia_numvals; i++) { - if (isvalidusername(&a->a_vals[i])) { - ber_dupbv_x(&members[j],&a->a_vals[i],cbp->op->o_tmpmemctx); - j++; + if ( a ) { + for (i=0; ia_numvals; i++) { + if (isvalidusername(&a->a_vals[i])) { + ber_dupbv_x(&members[j],&a->a_vals[i],cbp->op->o_tmpmemctx); + j++; + } } } - } - a = b; - if ( a ) { - for (i=0; ia_numvals; i++) { - if (nssov_dn2uid(cbp->op,cbp->ni,&a->a_nvals[i],&members[j])) - j++; + a = b; + if ( a ) { + for (i=0; ia_numvals; i++) { + if (nssov_dn2uid(cbp->op,cbp->ni,&a->a_nvals[i],&members[j])) + j++; + } } + nummembers = j; + BER_BVZERO(&members[j]); + } else { + members=NULL; + nummembers = 0; } - nummembers = j; - BER_BVZERO(&members[j]); + } else { members=NULL; nummembers = 0; -- 2.39.5