From e37ccca9aa6a0cf5ea521adbf110901c9b8f229c Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 7 Oct 2002 19:58:10 +0000 Subject: [PATCH] Fix ldap_int_get_controls for optional values --- libraries/libldap/controls.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/libraries/libldap/controls.c b/libraries/libldap/controls.c index f3af141e1e..3d9f3a5ac5 100644 --- a/libraries/libldap/controls.c +++ b/libraries/libldap/controls.c @@ -187,33 +187,27 @@ int ldap_int_get_controls( tag = ber_scanf( ber, "{a" /*}*/, &tctrl->ldctl_oid ); - if( tag != LBER_ERROR ) { - tag = ber_peek_tag( ber, &len ); + if( tag == LBER_ERROR ) { + *ctrls = NULL; + ldap_controls_free( tctrls ); + return LDAP_DECODING_ERROR; } + tag = ber_peek_tag( ber, &len ); + if( tag == LBER_BOOLEAN ) { ber_int_t crit; tag = ber_scanf( ber, "b", &crit ); tctrl->ldctl_iscritical = crit ? (char) 0 : (char) ~0; - } - - if( tag != LBER_ERROR ) { tag = ber_peek_tag( ber, &len ); } if( tag == LBER_OCTETSTRING ) { tag = ber_scanf( ber, "o", &tctrl->ldctl_value ); - } else { tctrl->ldctl_value.bv_val = NULL; } - if( tag == LBER_ERROR ) { - *ctrls = NULL; - ldap_controls_free( tctrls ); - return LDAP_DECODING_ERROR; - } - *ctrls = tctrls; } -- 2.39.5