]> git.sur5r.net Git - openldap/commitdiff
Don't crash on empty groups (ITS#5800)
authorRalf Haferkamp <ralf@openldap.org>
Mon, 10 Nov 2008 14:24:29 +0000 (14:24 +0000)
committerRalf Haferkamp <ralf@openldap.org>
Mon, 10 Nov 2008 14:24:29 +0000 (14:24 +0000)
contrib/slapd-modules/nssov/group.c

index 4cbdf7b4afc7fe423e2abd292bd189b3b56e5935..4c13acedbadd8bdccd4143cd31745564c1252c00 100644 (file)
@@ -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; i<a->a_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; i<a->a_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; i<a->a_numvals; i++) {
-                               if (nssov_dn2uid(cbp->op,cbp->ni,&a->a_nvals[i],&members[j]))
-                                       j++;
+                       a = b;
+                       if ( a ) {
+                               for (i=0; i<a->a_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;