svn commit: samba r18910 - in branches: SAMBA_3_0/source/lib/ldb/common SAMBA_4_0/source/lib/ldb/common

tridge at samba.org tridge at samba.org
Tue Sep 26 01:21:35 GMT 2006


Author: tridge
Date: 2006-09-26 01:21:34 +0000 (Tue, 26 Sep 2006)
New Revision: 18910

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18910

Log:
Change ldb_msg_add_string() to not actually add an attribute if the
string is zero length. This allows callers to not have to worry about
creating an invalid ldap attribute.

See extensive discussion on samba-technical list :-)


Modified:
   branches/SAMBA_3_0/source/lib/ldb/common/ldb_msg.c
   branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/ldb/common/ldb_msg.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/common/ldb_msg.c	2006-09-25 22:55:56 UTC (rev 18909)
+++ branches/SAMBA_3_0/source/lib/ldb/common/ldb_msg.c	2006-09-26 01:21:34 UTC (rev 18910)
@@ -227,6 +227,11 @@
 	val.data = discard_const_p(uint8_t, str);
 	val.length = strlen(str);
 
+	if (val.length == 0) {
+		/* allow empty strings as non-existant attributes */
+		return 0;
+	}
+
 	return ldb_msg_add_value(msg, attr_name, &val);
 }
 

Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c	2006-09-25 22:55:56 UTC (rev 18909)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c	2006-09-26 01:21:34 UTC (rev 18910)
@@ -227,6 +227,11 @@
 	val.data = discard_const_p(uint8_t, str);
 	val.length = strlen(str);
 
+	if (val.length == 0) {
+		/* allow empty strings as non-existant attributes */
+		return LDB_SUCCESS;
+	}
+
 	return ldb_msg_add_value(msg, attr_name, &val);
 }
 



More information about the samba-cvs mailing list