]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/config.c
op->o_conn->c_sb may be 0 for internal operations
[openldap] / servers / slapd / config.c
index 3f8388293defa4dd7c3c85fb3556896c5ba937d4..5ab500325c633a21a6e11c41cade4c8453f2e46d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2009 The OpenLDAP Foundation.
+ * Copyright 1998-2010 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -467,7 +467,7 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
                                c->value_string = ch_strdup(*(char **)ptr);
                        break;
                case ARG_BERVAL:
-                       ber_dupbv( &c->value_bv, (struct berval *)ptr ); break;
+                       c->value_bv = *((struct berval *)ptr); break;
                case ARG_ATDESC:
                        c->value_ad = *(AttributeDescription **)ptr; break;
                }
@@ -1288,6 +1288,9 @@ slap_keepalive_parse(
                }
 
                *sk = sk2;
+
+               ber_memfree( val->bv_val );
+               BER_BVZERO( val );
        }
 
        return 0;
@@ -1303,7 +1306,10 @@ slap_sb_uri(
 {
        slap_bindconf *bc = bcp;
        if ( unparse ) {
-               *val = bc->sb_uri;
+               if ( bc->sb_uri.bv_len >= val->bv_len )
+                       return -1;
+               val->bv_len = bc->sb_uri.bv_len;
+               AC_MEMCPY( val->bv_val, bc->sb_uri.bv_val, val->bv_len );
        } else {
                bc->sb_uri = *val;
 #ifdef HAVE_TLS
@@ -1539,23 +1545,31 @@ slap_cf_aux_table_unparse( void *src, struct berval *bv, slap_cf_aux_table *tab0
                        break;
 
                case 'x':
-                       *ptr++ = ' ';
-                       ptr = lutil_strcopy( ptr, tab->key.bv_val );
-                       if ( tab->quote ) *ptr++ = '"';
-                       if ( tab->aux != NULL ) {
-                               struct berval value;
-                               slap_cf_aux_table_parse_x *func = (slap_cf_aux_table_parse_x *)tab->aux;
-                               int rc;
+                       {
+                               char *saveptr=ptr;
+                               *ptr++ = ' ';
+                               ptr = lutil_strcopy( ptr, tab->key.bv_val );
+                               if ( tab->quote ) *ptr++ = '"';
+                               if ( tab->aux != NULL ) {
+                                       struct berval value;
+                                       slap_cf_aux_table_parse_x *func = (slap_cf_aux_table_parse_x *)tab->aux;
+                                       int rc;
 
-                               value.bv_val = ptr;
-                               value.bv_len = buf + sizeof( buf ) - ptr;
+                                       value.bv_val = ptr;
+                                       value.bv_len = buf + sizeof( buf ) - ptr;
 
-                               rc = func( &value, (void *)((char *)src + tab->off), tab, "(unparse)", 1 );
-                               if ( rc == 0 ) {
-                                       ptr += value.bv_len;
+                                       rc = func( &value, (void *)((char *)src + tab->off), tab, "(unparse)", 1 );
+                                       if ( rc == 0 ) {
+                                               if (value.bv_len) {
+                                                       ptr += value.bv_len;
+                                               } else {
+                                                       ptr = saveptr;
+                                                       break;
+                                               }
+                                       }
                                }
+                               if ( tab->quote ) *ptr++ = '"';
                        }
-                       if ( tab->quote ) *ptr++ = '"';
                        break;
 
                default: