X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fvlvctrl.c;h=1ecf5f4bee87b309a1e721ab9c9e11def4b669b9;hb=6c1d48aa8d066ff85809b8a544952ad2d1dc3400;hp=ab731007cd14aedb6785247701945a5972170efd;hpb=0ccbce9d097e5fd9a5cc6f3dcf9c08dfca50ab90;p=openldap diff --git a/libraries/libldap/vlvctrl.c b/libraries/libldap/vlvctrl.c index ab731007cd..1ecf5f4bee 100644 --- a/libraries/libldap/vlvctrl.c +++ b/libraries/libldap/vlvctrl.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2006 The OpenLDAP Foundation. + * Copyright 1998-2010 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,9 +27,6 @@ * can be found in the file "build/LICENSE-2.0.1" in this distribution * of OpenLDAP Software. */ -/* Portions Copyright (C) The Internet Society (1997) - * ASN.1 fragments are from RFC 2251; see RFC for full legal notices. - */ #include "portable.h" @@ -95,14 +92,16 @@ ldap_create_vlv_control_value( BerElement *ber; if ( ld == NULL || vlvinfop == NULL || value == NULL ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return ld->ld_errno; + if ( ld ) + ld->ld_errno = LDAP_PARAM_ERROR; + return LDAP_PARAM_ERROR; } assert( LDAP_VALID( ld ) ); value->bv_val = NULL; value->bv_len = 0; + ld->ld_errno = LDAP_SUCCESS; ber = ldap_alloc_ber_with_options( ld ); if ( ber == NULL ) { @@ -212,7 +211,6 @@ ldap_create_vlv_control( LDAPControl **ctrlp ) { struct berval value; - BerElement *ber; if ( ctrlp == NULL ) { ld->ld_errno = LDAP_PARAM_ERROR; @@ -221,19 +219,12 @@ ldap_create_vlv_control( ld->ld_errno = ldap_create_vlv_control_value( ld, vlvinfop, &value ); if ( ld->ld_errno == LDAP_SUCCESS ) { - if ((ber = ldap_alloc_ber_with_options(ld)) == NULL) { - ld->ld_errno = LDAP_NO_MEMORY; - return LDAP_NO_MEMORY; - } - ld->ld_errno = ldap_create_control( LDAP_CONTROL_VLVREQUEST, - ber, 1, ctrlp ); - if ( ld->ld_errno == LDAP_SUCCESS ) { - (*ctrlp)->ldctl_value = value; - } else { + ld->ld_errno = ldap_control_create( LDAP_CONTROL_VLVREQUEST, + 1, &value, 0, ctrlp ); + if ( ld->ld_errno != LDAP_SUCCESS ) { LDAP_FREE( value.bv_val ); } - ber_free(ber, 1); } return ld->ld_errno;