mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-25 00:59:45 -05:00
Always pass valid BerElement to ldap_create_control() to avoid assert fail
This commit is contained in:
parent
38d6716118
commit
0ccbce9d09
3 changed files with 24 additions and 3 deletions
|
|
@ -141,6 +141,7 @@ ldap_create_page_control(
|
|||
LDAPControl **ctrlp )
|
||||
{
|
||||
struct berval value;
|
||||
BerElement *ber;
|
||||
|
||||
if ( ctrlp == NULL ) {
|
||||
ld->ld_errno = LDAP_PARAM_ERROR;
|
||||
|
|
@ -150,13 +151,19 @@ ldap_create_page_control(
|
|||
ld->ld_errno = ldap_create_page_control_value( ld,
|
||||
pagesize, cookie, &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_PAGEDRESULTS,
|
||||
NULL, iscritical, ctrlp );
|
||||
ber, iscritical, ctrlp );
|
||||
if ( ld->ld_errno == LDAP_SUCCESS ) {
|
||||
(*ctrlp)->ldctl_value = value;
|
||||
} else {
|
||||
LDAP_FREE( value.bv_val );
|
||||
}
|
||||
ber_free(ber, 1);
|
||||
}
|
||||
|
||||
return ld->ld_errno;
|
||||
|
|
|
|||
|
|
@ -409,6 +409,7 @@ ldap_create_sort_control(
|
|||
LDAPControl **ctrlp )
|
||||
{
|
||||
struct berval value;
|
||||
BerElement *ber;
|
||||
|
||||
if ( ctrlp == NULL ) {
|
||||
ld->ld_errno = LDAP_PARAM_ERROR;
|
||||
|
|
@ -417,13 +418,19 @@ ldap_create_sort_control(
|
|||
|
||||
ld->ld_errno = ldap_create_sort_control_value( ld, keyList, &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_SORTREQUEST,
|
||||
NULL, isCritical, ctrlp );
|
||||
ber, isCritical, ctrlp );
|
||||
if ( ld->ld_errno == LDAP_SUCCESS ) {
|
||||
(*ctrlp)->ldctl_value = value;
|
||||
} else {
|
||||
LDAP_FREE( value.bv_val );
|
||||
}
|
||||
ber_free(ber, 1);
|
||||
}
|
||||
|
||||
return ld->ld_errno;
|
||||
|
|
|
|||
|
|
@ -212,6 +212,7 @@ ldap_create_vlv_control(
|
|||
LDAPControl **ctrlp )
|
||||
{
|
||||
struct berval value;
|
||||
BerElement *ber;
|
||||
|
||||
if ( ctrlp == NULL ) {
|
||||
ld->ld_errno = LDAP_PARAM_ERROR;
|
||||
|
|
@ -220,13 +221,19 @@ 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,
|
||||
NULL, 1, ctrlp );
|
||||
ber, 1, ctrlp );
|
||||
if ( ld->ld_errno == LDAP_SUCCESS ) {
|
||||
(*ctrlp)->ldctl_value = value;
|
||||
} else {
|
||||
LDAP_FREE( value.bv_val );
|
||||
}
|
||||
ber_free(ber, 1);
|
||||
}
|
||||
|
||||
return ld->ld_errno;
|
||||
|
|
|
|||
Loading…
Reference in a new issue