[patch] ldb_msg_add_string()

simo idra at samba.org
Mon Sep 25 03:01:29 GMT 2006


On Mon, 2006-09-25 at 10:57 +1000, tridge at samba.org wrote:
> 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);
>  }

No, I don't think we should allow this as it may conceal a programming
error in setting the attribute.
I'm just being defensive here, but I don't think the gain we have
through this is worth the possible loss.

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer
email: idra at samba.org
http://samba.org



More information about the samba-technical mailing list