r18910: Change ldb_msg_add_string() to not actually add an attribute if the
authorAndrew Tridgell <tridge@samba.org>
Tue, 26 Sep 2006 01:21:34 +0000 (01:21 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:20:20 +0000 (14:20 -0500)
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 :-)
(This used to be commit 7a1db8c2a432b9ab59b29ee1bfce6c8fe8e981a2)

source4/lib/ldb/common/ldb_msg.c

index 92c537a8fabf48bfb1ec5c427074afba08fb646e..9fbb2cdf3ea60ebf70218d9e64634d3271b8ee4a 100644 (file)
@@ -227,6 +227,11 @@ int ldb_msg_add_string(struct ldb_message *msg,
        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);
 }