]> git.sur5r.net Git - openldap/commitdiff
Fix ldap_int_get_controls for optional values
authorHoward Chu <hyc@openldap.org>
Mon, 7 Oct 2002 19:58:10 +0000 (19:58 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 7 Oct 2002 19:58:10 +0000 (19:58 +0000)
libraries/libldap/controls.c

index f3af141e1ea29c73ce025ceb104139fb37d23a78..3d9f3a5ac5606fcad6b7419e40649eb2677d012c 100644 (file)
@@ -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;
        }