[patch] ldb_msg_add_string()

tridge at samba.org tridge at samba.org
Mon Sep 25 00:57:18 GMT 2006


Simo,

Does the following ldb patch look OK to you? It's meant to prevent us
having bugs in code due to not handling the difference between empty
strings and non-empty strings. I got that wrong in my groupmap code,
and I would not be surprised if its wrong in other places too (I'm
quite sure that our test suite does not currently test all places
where a string is allowed to be empty, especially in the rpc server
code).

Cheers, Tridge


Index: common/ldb_msg.c
===================================================================
--- common/ldb_msg.c    (revision 18835)
+++ common/ldb_msg.c    (working copy)
@@ -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-technical mailing list