]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/pcache.c
fix uninitialized and off-by-one (thanks to valgrind)
[openldap] / servers / slapd / overlays / pcache.c
index fc886a30ce6a276e680af15405eef983e287d70e..0b74a736e0a39d55f9a261a79053aead7bbe6b10 100644 (file)
@@ -515,7 +515,7 @@ template_attrs( char *template, struct attr_set *set, AttributeName **ret,
 
        *ret = NULL;
 
-       attrs = ch_malloc(( set->count+1 )*sizeof(AttributeName));
+       attrs = ch_calloc( set->count + 1, sizeof(AttributeName) );
        for ( i=0; i < set->count; i++ )
                attrs[i] = set->attrs[i];
        attr_cnt = i;
@@ -2563,7 +2563,7 @@ pc_setpw( Operation *op, struct berval *pwd, cache_manager *cm )
                op->o_dn = op->o_bd->be_rootdn;
                op->o_ndn = op->o_bd->be_rootndn;
                op->o_callback = &cb;
-               Debug( pcache_debug, "pc_setpw: caching bind for %s\n",
+               Debug( pcache_debug, "pc_setpw: CACHING BIND for %s\n",
                        op->o_req_dn.bv_val, 0, 0 );
                rc = op->o_bd->be_modify( op, &sr );
                ch_free( vals[0].bv_val );
@@ -2845,6 +2845,9 @@ pcache_op_bind(
                BackendDB *be = op->o_bd;
                op->o_bd = &cm->db;
 
+               Debug( pcache_debug, "pcache_op_bind: CACHED BIND for %s\n",
+                       op->o_req_dn.bv_val, 0, 0 );
+
                if ( op->o_bd->be_bind( op, rs ) == LDAP_SUCCESS ) {
                        op->o_conn->c_authz_cookie = cm->db.be_private;
                }
@@ -3763,8 +3766,8 @@ pc_cf_gen( ConfigArgs *c )
                                        temp->attr_set_index,
                                        temp->bindttr,
                                        ldap_pvt_scope2str( temp->bindscope ));
-                               bv.bv_len += temp->bindbase.bv_len + temp->bindftemp.bv_len + 3;
-                               bv.bv_val = ch_malloc( bv.bv_len+1 );
+                               bv.bv_len += temp->bindbase.bv_len + temp->bindftemp.bv_len + 4;
+                               bv.bv_val = ch_malloc( bv.bv_len + 1 );
                                ptr = bv.bv_val;
                                *ptr++ = '"';
                                ptr = lutil_strcopy( ptr, temp->bindftemp.bv_val );