From 0207dcd3f925f9d1d458620183ac0916714ec488 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 3 Nov 2005 15:20:33 +0000 Subject: [PATCH] import leak plug from slapo-rwm --- servers/slapd/back-meta/config.c | 28 ++++++++++++++-------------- servers/slapd/back-meta/init.c | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/servers/slapd/back-meta/config.c b/servers/slapd/back-meta/config.c index 18f3a772d9..078d2ee0c6 100644 --- a/servers/slapd/back-meta/config.c +++ b/servers/slapd/back-meta/config.c @@ -939,17 +939,17 @@ ldap_back_map_config( fname, lineno ); return 1; } - ber_str2bv( src, 0, 1, &mapping->src ); - ber_str2bv( dst, 0, 1, &mapping->dst ); - mapping[ 1 ].src = mapping->dst; - mapping[ 1 ].dst = mapping->src; + ber_str2bv( src, 0, 1, &mapping[ 0 ].src ); + ber_str2bv( dst, 0, 1, &mapping[ 0 ].dst ); + mapping[ 1 ].src = mapping[ 0 ].dst; + mapping[ 1 ].dst = mapping[ 0 ].src; /* * schema check */ if ( is_oc ) { if ( src[ 0 ] != '\0' ) { - if ( oc_bvfind( &mapping->src ) == NULL ) { + if ( oc_bvfind( &mapping[ 0 ].src ) == NULL ) { fprintf( stderr, "%s: line %d: warning, source objectClass '%s' " "should be defined in schema\n", @@ -962,7 +962,7 @@ ldap_back_map_config( } } - if ( oc_bvfind( &mapping->dst ) == NULL ) { + if ( oc_bvfind( &mapping[ 0 ].dst ) == NULL ) { fprintf( stderr, "%s: line %d: warning, destination objectClass '%s' " "is not defined in schema\n", @@ -974,7 +974,7 @@ ldap_back_map_config( AttributeDescription *ad = NULL; if ( src[ 0 ] != '\0' ) { - rc = slap_bv2ad( &mapping->src, &ad, &text ); + rc = slap_bv2ad( &mapping[ 0 ].src, &ad, &text ); if ( rc != LDAP_SUCCESS ) { fprintf( stderr, "%s: line %d: warning, source attributeType '%s' " @@ -989,7 +989,7 @@ ldap_back_map_config( * and add it here. */ - rc = slap_bv2undef_ad( &mapping->src, + rc = slap_bv2undef_ad( &mapping[ 0 ].src, &ad, &text, SLAP_AD_PROXIED ); if ( rc != LDAP_SUCCESS ) { fprintf( stderr, @@ -1003,7 +1003,7 @@ ldap_back_map_config( ad = NULL; } - rc = slap_bv2ad( &mapping->dst, &ad, &text ); + rc = slap_bv2ad( &mapping[ 0 ].dst, &ad, &text ); if ( rc != LDAP_SUCCESS ) { fprintf( stderr, "%s: line %d: warning, destination attributeType '%s' " @@ -1015,7 +1015,7 @@ ldap_back_map_config( * and add it here. */ - rc = slap_bv2undef_ad( &mapping->dst, + rc = slap_bv2undef_ad( &mapping[ 0 ].dst, &ad, &text, SLAP_AD_PROXIED ); if ( rc != LDAP_SUCCESS ) { fprintf( stderr, @@ -1027,7 +1027,7 @@ ldap_back_map_config( } } - if ( (src[ 0 ] != '\0' && avl_find( map->map, (caddr_t)mapping, mapping_cmp ) != NULL) + if ( (src[ 0 ] != '\0' && avl_find( map->map, (caddr_t)&mapping[ 0 ], mapping_cmp ) != NULL) || avl_find( map->remap, (caddr_t)&mapping[ 1 ], mapping_cmp ) != NULL) { fprintf( stderr, @@ -1037,7 +1037,7 @@ ldap_back_map_config( } if ( src[ 0 ] != '\0' ) { - avl_insert( &map->map, (caddr_t)mapping, + avl_insert( &map->map, (caddr_t)&mapping[ 0 ], mapping_cmp, mapping_dup ); } avl_insert( &map->remap, (caddr_t)&mapping[ 1 ], @@ -1047,8 +1047,8 @@ ldap_back_map_config( error_return:; if ( mapping ) { - ch_free( mapping->src.bv_val ); - ch_free( mapping->dst.bv_val ); + ch_free( mapping[ 0 ].src.bv_val ); + ch_free( mapping[ 0 ].dst.bv_val ); ch_free( mapping ); } diff --git a/servers/slapd/back-meta/init.c b/servers/slapd/back-meta/init.c index b78a652ccc..a978646f1f 100644 --- a/servers/slapd/back-meta/init.c +++ b/servers/slapd/back-meta/init.c @@ -163,6 +163,17 @@ mapping_free( ch_free( mapping ); } +static void +mapping_dst_free( + void *v_mapping ) +{ + struct ldapmapping *mapping = v_mapping; + + if ( BER_BVISEMPTY( &mapping->dst ) ) { + mapping_free( &mapping[ -1 ] ); + } +} + static void target_free( metatarget_t *mt ) @@ -191,9 +202,9 @@ target_free( if ( mt->mt_rwmap.rwm_rw ) { rewrite_info_delete( &mt->mt_rwmap.rwm_rw ); } - avl_free( mt->mt_rwmap.rwm_oc.remap, NULL ); + avl_free( mt->mt_rwmap.rwm_oc.remap, mapping_dst_free ); avl_free( mt->mt_rwmap.rwm_oc.map, mapping_free ); - avl_free( mt->mt_rwmap.rwm_at.remap, NULL ); + avl_free( mt->mt_rwmap.rwm_at.remap, mapping_dst_free ); avl_free( mt->mt_rwmap.rwm_at.map, mapping_free ); } -- 2.39.5