[patch] ldb_msg_add_string()
tridge at samba.org
tridge at samba.org
Mon Sep 25 03:18:56 GMT 2006
Simo,
> No, I don't think we should allow this as it may conceal a programming
> error in setting the attribute.
hmm, I don't really understand this. Does this imply that
ldb_msg_add_string(ldb, "comment", "");
is a programming error, whereas
ldb_msg_add_string(ldb, "comment", "foo");
isn't ?
I could understand that NULL in that place is a programming error, but
I can't see how "" is an error.
> I'm just being defensive here, but I don't think the gain we have
> through this is worth the possible loss.
well, I'm pretty sure that right now we have real bugs due to
this. Just look at all the calls to samdb_msg_add_string(), which
calls ldb_msg_add_string(). I'd be surprised to find that every one of
those calls copes with the case where the string is zero length.
In C APIs, the usual convention is that there is a strong separation
of NULL strings from non-NULL strings, but no big distinction between
strings of length zero and strings of length 1.
As an alternative, we could have a:
ldb_msg_add_directory_string()
call, which gives an error on empty strings as that isn't within the
allowable syntax of "directory string" in ldap, but I think making our
default "set a C string" function refuse strings because they have
length zero is something that will bite us time and again :)
Cheers, Tridge
More information about the samba-technical
mailing list