From: Ralf Haferkamp Date: Mon, 10 Nov 2008 14:24:29 +0000 (+0000) Subject: Don't crash on empty groups (ITS#5800) X-Git-Tag: ACLCHECK_0~1142 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1d468467e623fb1c2010ddfa83d4f390d6c6b527;p=openldap Don't crash on empty groups (ITS#5800) --- 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;