Blob Blame History Raw
Don't unparse empty uri string.

Resolves: #628726
Upstream ITS: #6465 (http://www.openldap.org/its/index.cgi/Software%20Bugs?id=6465)

--- config.c	2010-09-16 12:52:26.595773834 +0200
+++ config.c	2010-09-16 12:51:30.492649769 +0200
@@ -1,5 +1,5 @@
 /* config.c - configuration file handling routines */
-/* $OpenLDAP: old/servers/slapd/config.c,v 1.512 2009/12/18 18:07:16 ando Exp $ */
+/* $OpenLDAP: new/servers/slapd/config.c,v 1.513 2010/02/02 13:43:21 ralf Exp $ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
  * Copyright 1998-2009 The OpenLDAP Foundation.
@@ -1545,23 +1545,31 @@
 			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: