X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fcontrols.c;h=52fae3b09028f2797f8097eabb1568c08dc6cd23;hb=a5ee438c9394a19a241716d3d922299c20b0365d;hp=09267a8bb2fa43c3bb63a23c48c1017fa00ee9e4;hpb=42304b7ada72a8a19cac0e0422b26dfe27c42f51;p=openldap diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index 09267a8bb2..52fae3b090 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -1,5 +1,6 @@ +/* $OpenLDAP$ */ /* - * Copyright 1999 The OpenLDAP Foundation. + * Copyright 1999-2000 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms are permitted only @@ -10,6 +11,8 @@ #include "portable.h" #include + +#include #include #include "slap.h" @@ -18,6 +21,7 @@ char *supportedControls[] = { LDAP_CONTROL_MANAGEDSAIT, +/* LDAP_CONTROL_X_CHANGE_PASSWD, */ NULL }; @@ -26,7 +30,7 @@ int get_ctrls( Operation *op, int sendres ) { - int nctrls; + int nctrls = 0; ber_tag_t tag; ber_len_t len; char *opaque; @@ -40,12 +44,12 @@ int get_ctrls( if( len == 0) { /* no controls */ rc = LDAP_SUCCESS; - goto return_results; + return rc; } if(( tag = ber_peek_tag( ber, &len )) != LDAP_TAG_CONTROLS ) { if( tag == LBER_ERROR ) { - rc = -1; + rc = SLAPD_DISCONNECT; errmsg = "unexpected data in PDU"; } @@ -55,13 +59,12 @@ int get_ctrls( Debug( LDAP_DEBUG_TRACE, "=> get_ctrls\n", 0, 0, 0 ); if( op->o_protocol < LDAP_VERSION3 ) { - rc = -1; + rc = SLAPD_DISCONNECT; errmsg = "controls require LDAPv3"; goto return_results; } /* set through each element */ - nctrls = 0; *ctrls = ch_malloc( 1 * sizeof(LDAPControl *) ); #if 0 @@ -72,7 +75,7 @@ int get_ctrls( } #endif - ctrls[nctrls] = NULL; + *ctrls[nctrls] = NULL; for( tag = ber_first_element( ber, &len, &opaque ); tag != LBER_ERROR; @@ -118,14 +121,11 @@ int get_ctrls( 0, 0, 0 ); *ctrls = NULL; ldap_controls_free( tctrls ); - rc = -1; + rc = SLAPD_DISCONNECT; errmsg = "decoding controls error"; goto return_results; } - Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: %s\n", - tctrl->ldctl_oid, 0, 0 ); - tag = ber_peek_tag( ber, &len ); if( tag == LBER_BOOLEAN ) { @@ -137,15 +137,20 @@ int get_ctrls( 0, 0, 0 ); *ctrls = NULL; ldap_controls_free( tctrls ); - rc = -1; + rc = SLAPD_DISCONNECT; errmsg = "decoding controls error"; goto return_results; } - tctrl->ldctl_iscritical = crit ? (char) 0 : (char) ~0; + tctrl->ldctl_iscritical = (crit != 0); tag = ber_peek_tag( ber, &len ); } + Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: oid=\"%s\" (%scritical)\n", + tctrl->ldctl_oid, + tctrl->ldctl_iscritical ? "" : "non", + 0 ); + if( tag == LBER_OCTETSTRING ) { tag = ber_scanf( ber, "o", &tctrl->ldctl_value ); @@ -154,7 +159,7 @@ int get_ctrls( 0, 0, 0 ); *ctrls = NULL; ldap_controls_free( tctrls ); - rc = -1; + rc = SLAPD_DISCONNECT; errmsg = "decoding controls error"; goto return_results; } @@ -176,7 +181,7 @@ return_results: nctrls, rc, errmsg ? errmsg : ""); if( sendres && rc != LDAP_SUCCESS ) { - if( rc == -1 ) { + if( rc == SLAPD_DISCONNECT ) { send_ldap_disconnect( conn, op, rc, errmsg ); } else { send_ldap_result( conn, op, rc,