]> git.sur5r.net Git - openldap/commitdiff
Minor cleanup (coverity)
authorHoward Chu <hyc@symas.com>
Sun, 18 Jan 2015 14:17:44 +0000 (14:17 +0000)
committerHoward Chu <hyc@symas.com>
Sun, 18 Jan 2015 14:17:44 +0000 (14:17 +0000)
servers/slapd/overlays/constraint.c
servers/slapd/overlays/dynlist.c
servers/slapd/overlays/pcache.c
servers/slapd/overlays/ppolicy.c
servers/slapd/overlays/rwmmap.c
servers/slapd/overlays/translucent.c

index 096f32aa79a225c7885c13af560b5e0a68c769af..33323e399d4225ba41563a9fde98d1003867e8fc 100644 (file)
@@ -980,16 +980,6 @@ constraint_update( Operation *op, SlapReply *rs )
        /* Do we need to count attributes? */
        for(cp = c; cp; cp = cp->ap_next) {
                if (cp->type == CONSTRAINT_COUNT) {
-                       if (rc != 0 || target_entry == NULL) {
-                               Debug(LDAP_DEBUG_TRACE, 
-                                       "==> constraint_update rc = %d DN=\"%s\"%s\n",
-                                       rc, op->o_req_ndn.bv_val,
-                                       target_entry ? "" : " not found" );
-                               if ( rc == 0 ) 
-                                       rc = LDAP_CONSTRAINT_VIOLATION;
-                               goto mod_violation;
-                       }
-
                        if (cp->restrict_lud && constraint_check_restrict(op, cp, target_entry) == 0) {
                                continue;
                        }
index b5146ed7868262807ce6c25b809ca9ce66f8018b..bdd9f2555f90d80eba63cce35eed05b48c372cf7 100644 (file)
@@ -1158,6 +1158,12 @@ done_uri:;
                                        filter_free( filter );
                                }
 
+                               while ( dlm != NULL ) {
+                                       dlml = dlm;
+                                       dlm = dlm->dlm_next;
+                                       ch_free( dlml );
+                               }
+
                                Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
                                        c->log, c->cr_msg, 0 );
 
@@ -1174,7 +1180,8 @@ done_uri:;
                                c->argv[ attridx ] );
                        Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
                                c->log, c->cr_msg, 0 );
-                       return 1;
+                       rc = 1;
+                       goto done_uri;
                }
 
                if ( !is_at_subtype( ad->ad_type, slap_schema.si_ad_labeledURI->ad_type ) ) {
@@ -1184,7 +1191,8 @@ done_uri:;
                                c->argv[ attridx ] );
                        Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
                                c->log, c->cr_msg, 0 );
-                       return 1;
+                       rc = 1;
+                       goto done_uri;
                }
 
                attridx++;
@@ -1213,7 +1221,8 @@ done_uri:;
                                                i - 3, c->argv[ i ] );
                                        Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
                                                c->log, c->cr_msg, 0 );
-                                       return 1;
+                                       rc = 1;
+                                       goto done_uri;
                                }
                                arg = cp + 1;
                        }
@@ -1226,7 +1235,8 @@ done_uri:;
                                        i - 3, c->argv[ i ] );
                                Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
                                        c->log, c->cr_msg, 0 );
-                               return 1;
+                               rc = 1;
+                               goto done_uri;
                        }
 
                        dlmp = (dynlist_map_t *)ch_calloc( 1, sizeof( dynlist_map_t ) );
@@ -1255,7 +1265,8 @@ done_uri:;
                                                c->valx );
                                        Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
                                                c->log, c->cr_msg, 0 );
-                                       return 1;
+                                       rc = 1;
+                                       goto done_uri;
                                }
                                dlip = &(*dlip)->dli_next;
                        }
index 19ead342914238375fb846a1e9899ffa241fc4d3..2261ec2edb6233a0fc10b73022ea8e84427dc396 100644 (file)
@@ -457,8 +457,13 @@ ftemp_attrs( struct berval *ftemp, struct berval *template,
                        *t1++ = *p1++;
 
                p2 = strchr( p1, '=' );
-               if ( !p2 )
+               if ( !p2 ) {
+                       if ( !descs ) {
+                               ch_free( temp2 );
+                               return -1;
+                       }
                        break;
+               }
                i = p2 - p1;
                AC_MEMCPY( t1, p1, i );
                t1 += i;
@@ -470,6 +475,7 @@ ftemp_attrs( struct berval *ftemp, struct berval *template,
                ad = NULL;
                i = slap_bv2ad( &bv, &ad, text );
                if ( i ) {
+                       ch_free( temp2 );
                        ch_free( descs );
                        return -1;
                }
@@ -565,6 +571,7 @@ bottom:
        }
        if ( !t_cnt ) {
                *text = "couldn't parse template";
+               ch_free(attrs);
                return -1;
        }
        if ( !got_oc && !( set->flags & PC_GOT_OC )) {
index 19ffdb6f1752ec683495cca24f6c4cd3e97d0a07..1c365f473eb279ab7e8de5821bd1e4136f2a6756 100644 (file)
@@ -378,6 +378,7 @@ create_passcontrol( Operation *op, int exptime, int grace, LDAPPasswordPolicyErr
        BerElement *ber = (BerElement *) &berbuf, *b2 = (BerElement *) &bb2;
        LDAPControl c = { 0 }, *cp;
        struct berval bv;
+       int rc;
 
        BER_BVZERO( &c.ldctl_value );
 
@@ -387,15 +388,23 @@ create_passcontrol( Operation *op, int exptime, int grace, LDAPPasswordPolicyErr
        if ( exptime >= 0 ) {
                ber_init2( b2, NULL, LBER_USE_DER );
                ber_printf( b2, "ti", PPOLICY_EXPIRE, exptime );
-               ber_flatten2( b2, &bv, 1 );
+               rc = ber_flatten2( b2, &bv, 1 );
                (void)ber_free_buf(b2);
+               if (rc == -1) {
+                       cp = NULL;
+                       goto fail;
+               }
                ber_printf( ber, "tO", PPOLICY_WARNING, &bv );
                ch_free( bv.bv_val );
        } else if ( grace > 0 ) {
                ber_init2( b2, NULL, LBER_USE_DER );
                ber_printf( b2, "ti", PPOLICY_GRACE, grace );
-               ber_flatten2( b2, &bv, 1 );
+               rc = ber_flatten2( b2, &bv, 1 );
                (void)ber_free_buf(b2);
+               if (rc == -1) {
+                       cp = NULL;
+                       goto fail;
+               }
                ber_printf( ber, "tO", PPOLICY_WARNING, &bv );
                ch_free( bv.bv_val );
        }
@@ -414,6 +423,7 @@ create_passcontrol( Operation *op, int exptime, int grace, LDAPPasswordPolicyErr
        cp->ldctl_value.bv_val = (char *)&cp[1];
        cp->ldctl_value.bv_len = c.ldctl_value.bv_len;
        AC_MEMCPY( cp->ldctl_value.bv_val, c.ldctl_value.bv_val, c.ldctl_value.bv_len );
+fail:
        (void)ber_free_buf(ber);
        
        return cp;
index 4594353c98e471c608aacfcee7c91294bfb50d51..c12d413759c6a461b026c048c097c1b3790813ce 100644 (file)
@@ -215,7 +215,9 @@ rwm_map_attrnames(
                return LDAP_NO_MEMORY;
        }
 
-       for ( i = 0, j = 0; !BER_BVISNULL( &an[i].an_name ); i++ ) {
+       j = 0;
+       if ( an != NULL ) {
+       for ( i = 0; !BER_BVISNULL( &an[i].an_name ); i++ ) {
                struct ldapmapping      *m;
                int                     at_drop_missing = 0,
                                        oc_drop_missing = 0;
@@ -331,6 +333,7 @@ rwm_map_attrnames(
                        }
                }
        }
+       }
 
        if ( op->o_bd->be_extra_anlist != NULL ) {
                /* we assume be_extra_anlist are already mapped */
index a8846b10a1a404208605df5e918936cd15a8c215..b7de2cb3be11a00697c7778ed7cf0a6ad12f2d64 100644 (file)
@@ -420,12 +420,12 @@ static int translucent_modify(Operation *op, SlapReply *rs) {
        op->o_bd = &ov->db;
        ov->db.be_acl = op->o_bd->be_acl;
        rc = ov->db.bd_info->bi_entry_get_rw(op, &op->o_req_ndn, NULL, NULL, 0, &re);
+       op->o_bd = db;
        if(rc != LDAP_SUCCESS || re == NULL ) {
                send_ldap_error((op), rs, LDAP_NO_SUCH_OBJECT,
                        "attempt to modify nonexistent local record");
                return(rs->sr_err);
        }
-       op->o_bd = db;
 /*
 ** fetch entry from local backend;
 ** if it exists:
@@ -788,7 +788,7 @@ static int translucent_search_cb(Operation *op, SlapReply *rs) {
        if ( rs->sr_type == REP_RESULT && ( tc->step & USE_LIST ))
                return 0;
 
-       if(!op || !rs || rs->sr_type != REP_SEARCH || !rs->sr_entry)
+       if(rs->sr_type != REP_SEARCH || !rs->sr_entry)
                return(SLAP_CB_CONTINUE);
 
        Debug(LDAP_DEBUG_TRACE, "==> translucent_search_cb: %s\n",