X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fcontrols.c;h=b609b7bc5660cd0c180fe2df01663248bda74c69;hb=8482d2b4889b32f70c51144ac73423dd4e8ddc14;hp=9262bcb955d9d5eaa87abfcef8326337a97d8b1a;hpb=1f52f6e43e678c8f77625f5c96105a1bb51cc1ce;p=openldap diff --git a/libraries/libldap/controls.c b/libraries/libldap/controls.c index 9262bcb955..b609b7bc56 100644 --- a/libraries/libldap/controls.c +++ b/libraries/libldap/controls.c @@ -2,13 +2,21 @@ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ -/* - * LDAP controls + +/* LDAPv3 Controls (RFC2251) + * + * Controls ::= SEQUENCE OF Control + * + * Control ::= SEQUENCE { + * controlType LDAPOID, + * criticality BOOLEAN DEFAULT FALSE, + * controlValue OCTET STRING OPTIONAL + * } */ #include "portable.h" -#include +#include #include #include @@ -54,13 +62,13 @@ int ldap_int_put_controls( } /* Controls are encoded as a sequence of sequences */ - if( ber_printf( ber, "t{", LDAP_TAG_CONTROLS ) == -1 ) { + if( ber_printf( ber, "t{"/*}*/, LDAP_TAG_CONTROLS ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; return ld->ld_errno; } for( c = ctrls ; *c != NULL; c++ ) { - if ( ber_printf( ber, "{s", + if ( ber_printf( ber, "{s" /*}*/, (*c)->ldctl_oid ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; @@ -69,7 +77,7 @@ int ldap_int_put_controls( if( (*c)->ldctl_iscritical /* only if true */ && ( ber_printf( ber, "b", - (*c)->ldctl_iscritical ) == -1 ) ) + (ber_int_t) (*c)->ldctl_iscritical ) == -1 ) ) { ld->ld_errno = LDAP_ENCODING_ERROR; return ld->ld_errno; @@ -84,14 +92,14 @@ int ldap_int_put_controls( } - if( ber_printf( ber, "}" ) == -1 ) { + if( ber_printf( ber, /*{*/"}" ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; return ld->ld_errno; } } - if( ber_printf( ber, "}" ) == -1 ) { + if( ber_printf( ber, /*{*/"}" ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; return ld->ld_errno; } @@ -99,12 +107,13 @@ int ldap_int_put_controls( return LDAP_SUCCESS; } -int ldap_int_get_controls LDAP_P(( +int ldap_int_get_controls( BerElement *ber, - LDAPControl ***ctrls )) + LDAPControl ***ctrls ) { int nctrls; - unsigned long tag, len; + ber_tag_t tag; + ber_len_t len; char *opaque; assert( ber != NULL ); @@ -171,14 +180,16 @@ int ldap_int_get_controls LDAP_P(( tctrls[nctrls++] = tctrl; tctrls[nctrls] = NULL; - tag = ber_scanf( ber, "{a", &tctrl->ldctl_oid ); + tag = ber_scanf( ber, "{a" /*}*/, &tctrl->ldctl_oid ); if( tag != LBER_ERROR ) { tag = ber_peek_tag( ber, &len ); } if( tag == LBER_BOOLEAN ) { - tag = ber_scanf( ber, "b", &tctrl->ldctl_iscritical ); + ber_int_t crit; + tag = ber_scanf( ber, "b", &crit ); + tctrl->ldctl_iscritical = crit ? (char) 0 : (char) ~0; } if( tag != LBER_ERROR ) { @@ -210,6 +221,8 @@ int ldap_int_get_controls LDAP_P(( void ldap_control_free( LDAPControl *c ) { + assert( c != NULL ); + if ( c != NULL ) { if( c->ldctl_oid != NULL) { LDAP_FREE( c->ldctl_oid ); @@ -229,6 +242,8 @@ ldap_control_free( LDAPControl *c ) void ldap_controls_free( LDAPControl **controls ) { + assert( controls != NULL ); + if ( controls != NULL ) { LDAPControl *c; @@ -243,7 +258,7 @@ ldap_controls_free( LDAPControl **controls ) /* * Duplicate an array of LDAPControl */ -LDAPControl **ldap_controls_dup( const LDAPControl **controls ) +LDAPControl **ldap_controls_dup( LDAPControl **controls ) { LDAPControl **new; int i; @@ -285,7 +300,7 @@ LDAPControl **ldap_controls_dup( const LDAPControl **controls ) /* * Duplicate a LDAPControl */ -LDAPControl *ldap_control_dup( const LDAPControl *c ) +LDAPControl *ldap_control_dup( LDAPControl *c ) { LDAPControl *new;