[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Problems in LDAPControl handling



At 11:27 PM 10/12/00 -0500, Salvador Ortiz Garcia wrote:
>I know that the C API documentation in the 2.x series its incomplete, so
>for my proyect I'm using both the (expired) c-api draft and the sources as
>a reference.

You're welcomed to help update the docs...

>While reading controls.c I found what IMHO is a bug in ldap_create_control
>and a potential problem in ldap_control_dup (both undocumented yet but
>very useful):
>
>First the bug:
>
>ldap_control_create returns LDAP_PARAM_ERROR when ber == NULL, a
>BUG in my opinion because it is perfectly valid to create a control
>without a controlValue.

Yes.

>In the draft, in 11.3 "Working With Controls" i can read:
>
>   ldctl_value      The data associated with the control (if any).  To
>                    specify a zero-length value, set ldctl_value.bv_len to
>                    zero and ldctl_value.bv_val to a zero-length string.
>                    To indicate that no data is associated with the con-
>                    trol, set ldctl_value.bv_val to NULL.
>
>So we have two diferent cases with bv_len == 0, that makes sense to 
>me because in the ASN1 a controlValue is defined as OCTECT STRING OPTIONAL
>so 
>
>'bv_len == 0, bv_val == NULL' eq "no controlValue" 
>
>and
>
>'bv_len == 0, bv_val == ""' supplies a empty but existent controlValue.



>But in ldap_control_dup i read:
>
>        if( c->ldctl_value.bv_len > 0 ) {

this should be c->ldctl_value.bv_val != NULL ...

>I don't know if in reallity can be a ldap control with diferent
>semantics for the two cases, so I'm asking you for some expert advise.

It certainly is possible to define a control where the semantics
of not present and empty differ.  Not present is often used to
default the semantics and defaults many be quite different
than the empty value case.

I've committed a couple of changes which should resolve these
issues.