mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-09 02:52:04 +08:00
Add LBER_ and LDAP_ memory allocators/deallocators for internal
library use: LBER_ macros expand to system routines. LDAP_ macros expand to new ber_ allocators. Add ber_ and ldap_ memory allocators/deallocator: ber_ routines are wrappers of LBER_ macros. ldap_ routines are wrappers of ber_ routines. Removed safe_realloc() macro from various files. This issue (if an issue) should be resolved across whole package. ldapmodify.c now uses ber_ allocators to resolve ber_bvfree() vs. WIN32 multiple heaps issue. These changes should facilate implementation of ber_set_option( NULL, LBER_OPT_MEMORY_FN, ...) and ldap_set_option( NULL, LDAP_OPT_MEMORY_FN, ...).
This commit is contained in:
parent
27caa58f51
commit
1bcec8bf6a
@ -21,9 +21,6 @@ static int ldapport = 0;
|
||||
static int not, verbose, contoper;
|
||||
static LDAP *ld;
|
||||
|
||||
#define safe_realloc( ptr, size ) ( (ptr) == NULL ? malloc( size ) : \
|
||||
realloc( ptr, size ))
|
||||
|
||||
static int dodelete LDAP_P((
|
||||
LDAP *ld,
|
||||
char *dn));
|
||||
|
@ -35,9 +35,6 @@ static int ldapport = 0;
|
||||
static int new, replace, not, verbose, contoper, force, valsfromfiles;
|
||||
static LDAP *ld;
|
||||
|
||||
#define safe_realloc( ptr, size ) ( (ptr) == NULL ? malloc( size ) : \
|
||||
realloc( ptr, size ))
|
||||
|
||||
#define LDAPMOD_MAXLINE 4096
|
||||
|
||||
/* strings found in replog/LDIF entries (mostly lifted from slurpd/slurp.h) */
|
||||
@ -589,9 +586,9 @@ addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
|
||||
}
|
||||
|
||||
if ( pmods == NULL || pmods[ i ] == NULL ) {
|
||||
if (( pmods = (LDAPMod **)safe_realloc( pmods, (i + 2) *
|
||||
if (( pmods = (LDAPMod **)realloc( pmods, (i + 2) *
|
||||
sizeof( LDAPMod * ))) == NULL ) {
|
||||
perror( "safe_realloc" );
|
||||
perror( "realloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
*pmodsp = pmods;
|
||||
@ -616,15 +613,15 @@ addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
|
||||
}
|
||||
}
|
||||
if (( pmods[ i ]->mod_bvalues =
|
||||
(struct berval **)safe_realloc( pmods[ i ]->mod_bvalues,
|
||||
(struct berval **)ber_memrealloc( pmods[ i ]->mod_bvalues,
|
||||
(j + 2) * sizeof( struct berval * ))) == NULL ) {
|
||||
perror( "safe_realloc" );
|
||||
perror( "ber_realloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
|
||||
if (( bvp = (struct berval *)malloc( sizeof( struct berval )))
|
||||
if (( bvp = (struct berval *)ber_memalloc( sizeof( struct berval )))
|
||||
== NULL ) {
|
||||
perror( "malloc" );
|
||||
perror( "ber_memalloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
pmods[ i ]->mod_bvalues[ j ] = bvp;
|
||||
@ -762,34 +759,6 @@ domodrdn( char *dn, char *newrdn, int deleteoldrdn )
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* for Windows we need local versions of the berval
|
||||
* free functions because the LDAP DLL uses a different
|
||||
* heap.
|
||||
*/
|
||||
|
||||
static void
|
||||
l_ber_bvfree( struct berval *bv )
|
||||
{
|
||||
if ( bv != NULL ) {
|
||||
if ( bv->bv_val != NULL ) {
|
||||
free( bv->bv_val );
|
||||
}
|
||||
free( (char *) bv );
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
l_ber_bvecfree( struct berval **bv )
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; bv[i] != NULL; i++ ) {
|
||||
l_ber_bvfree( bv[i] );
|
||||
}
|
||||
free( (char *) bv );
|
||||
}
|
||||
|
||||
static void
|
||||
freepmods( LDAPMod **pmods )
|
||||
{
|
||||
@ -797,7 +766,7 @@ freepmods( LDAPMod **pmods )
|
||||
|
||||
for ( i = 0; pmods[ i ] != NULL; ++i ) {
|
||||
if ( pmods[ i ]->mod_bvalues != NULL ) {
|
||||
l_ber_bvecfree( pmods[ i ]->mod_bvalues );
|
||||
ber_bvecfree( pmods[ i ]->mod_bvalues );
|
||||
}
|
||||
if ( pmods[ i ]->mod_type != NULL ) {
|
||||
free( pmods[ i ]->mod_type );
|
||||
@ -869,8 +838,8 @@ read_one_record( FILE *fp )
|
||||
if ( lcur + len + 1 > lmax ) {
|
||||
lmax = LDAPMOD_MAXLINE
|
||||
* (( lcur + len + 1 ) / LDAPMOD_MAXLINE + 1 );
|
||||
if (( buf = (char *)safe_realloc( buf, lmax )) == NULL ) {
|
||||
perror( "safe_realloc" );
|
||||
if (( buf = (char *)realloc( buf, lmax )) == NULL ) {
|
||||
perror( "realloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
@ -33,9 +33,6 @@ static int ldapport = 0;
|
||||
static int not, verbose, contoper;
|
||||
static LDAP *ld;
|
||||
|
||||
#define safe_realloc( ptr, size ) ( (ptr) == NULL ? malloc( size ) : \
|
||||
realloc( ptr, size ))
|
||||
|
||||
static int domodrdn LDAP_P((
|
||||
LDAP *ld,
|
||||
char *dn,
|
||||
|
@ -424,6 +424,26 @@ LDAP_F( void )
|
||||
ber_sockbuf_free(
|
||||
Sockbuf *sb );
|
||||
|
||||
/*
|
||||
* LBER memory.c
|
||||
*/
|
||||
LDAP_F( void * )
|
||||
ber_memalloc LDAP_P((
|
||||
size_t s ));
|
||||
|
||||
LDAP_F( void * )
|
||||
ber_memrealloc LDAP_P((
|
||||
void* p,
|
||||
size_t s ));
|
||||
|
||||
LDAP_F( void * )
|
||||
ber_memcalloc LDAP_P((
|
||||
size_t n,
|
||||
size_t s ));
|
||||
|
||||
LDAP_F( void )
|
||||
ber_memfree LDAP_P((
|
||||
void* p ));
|
||||
|
||||
LDAP_END_DECL
|
||||
|
||||
|
@ -1330,9 +1330,23 @@ ldap_build_filter LDAP_P((
|
||||
* in free.c
|
||||
*/
|
||||
|
||||
LDAP_F( void * )
|
||||
ldap_memalloc LDAP_P((
|
||||
size_t s ));
|
||||
|
||||
LDAP_F( void * )
|
||||
ldap_memrealloc LDAP_P((
|
||||
void* p,
|
||||
size_t s ));
|
||||
|
||||
LDAP_F( void * )
|
||||
ldap_memcalloc LDAP_P((
|
||||
size_t n,
|
||||
size_t s ));
|
||||
|
||||
LDAP_F( void )
|
||||
ldap_memfree LDAP_P((
|
||||
void *p ));
|
||||
void* p ));
|
||||
|
||||
LDAP_F( void )
|
||||
ldap_getfilter_free LDAP_P((
|
||||
|
@ -237,11 +237,11 @@ ber_get_stringb( BerElement *ber, char *buf, unsigned long *len )
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
if ( datalen > *len ) {
|
||||
free( transbuf );
|
||||
LBER_FREE( transbuf );
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
SAFEMEMCPY( buf, transbuf, datalen );
|
||||
free( transbuf );
|
||||
LBER_FREE( transbuf );
|
||||
--datalen;
|
||||
}
|
||||
#endif /* STR_TRANSLATION */
|
||||
@ -265,11 +265,11 @@ ber_get_stringa( BerElement *ber, char **buf )
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
|
||||
if ( (*buf = (char *) malloc( (size_t)datalen + 1 )) == NULL )
|
||||
if ( (*buf = (char *) LBER_MALLOC( (size_t)datalen + 1 )) == NULL )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( (unsigned long) ber_read( ber, *buf, datalen ) != datalen ) {
|
||||
free( *buf );
|
||||
LBER_FREE( *buf );
|
||||
*buf = NULL;
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
@ -281,7 +281,7 @@ ber_get_stringa( BerElement *ber, char **buf )
|
||||
++datalen;
|
||||
if ( (*(ber->ber_decode_translate_proc))( buf, &datalen, 1 )
|
||||
!= 0 ) {
|
||||
free( *buf );
|
||||
LBER_FREE( *buf );
|
||||
*buf = NULL;
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
@ -306,11 +306,11 @@ ber_get_stringal( BerElement *ber, struct berval **bv )
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
|
||||
if ( (*bv = (struct berval *) malloc( sizeof(struct berval) )) == NULL )
|
||||
if ( (*bv = (struct berval *) LBER_MALLOC( sizeof(struct berval) )) == NULL )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( ((*bv)->bv_val = (char *) malloc( (size_t)len + 1 )) == NULL ) {
|
||||
free( *bv );
|
||||
if ( ((*bv)->bv_val = (char *) LBER_MALLOC( (size_t)len + 1 )) == NULL ) {
|
||||
LBER_FREE( *bv );
|
||||
*bv = NULL;
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
@ -358,17 +358,17 @@ ber_get_bitstringa( BerElement *ber, char **buf, unsigned long *blen )
|
||||
}
|
||||
--datalen;
|
||||
|
||||
if ( (*buf = (char *) malloc( (size_t)datalen )) == NULL )
|
||||
if ( (*buf = (char *) LBER_MALLOC( (size_t)datalen )) == NULL )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( ber_read( ber, (char *)&unusedbits, 1 ) != 1 ) {
|
||||
free( buf );
|
||||
LBER_FREE( buf );
|
||||
*buf = NULL;
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
|
||||
if ( (unsigned long) ber_read( ber, *buf, datalen ) != datalen ) {
|
||||
free( buf );
|
||||
LBER_FREE( buf );
|
||||
*buf = NULL;
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
@ -573,13 +573,9 @@ va_dcl
|
||||
tag != LBER_DEFAULT && rc != LBER_DEFAULT;
|
||||
tag = ber_next_element( ber, &len, last ) )
|
||||
{
|
||||
if ( *sss == NULL ) {
|
||||
*sss = (char **) malloc(
|
||||
2 * sizeof(char *) );
|
||||
} else {
|
||||
*sss = (char **) realloc( *sss,
|
||||
(j + 2) * sizeof(char *) );
|
||||
}
|
||||
*sss = (char **) LBER_REALLOC( *sss,
|
||||
(j + 2) * sizeof(char *) );
|
||||
|
||||
rc = ber_get_stringa( ber, &((*sss)[j]) );
|
||||
j++;
|
||||
}
|
||||
@ -595,13 +591,9 @@ va_dcl
|
||||
tag != LBER_DEFAULT && rc != LBER_DEFAULT;
|
||||
tag = ber_next_element( ber, &len, last ) )
|
||||
{
|
||||
if ( *bv == NULL ) {
|
||||
*bv = (struct berval **) malloc(
|
||||
2 * sizeof(struct berval *) );
|
||||
} else {
|
||||
*bv = (struct berval **) realloc( *bv,
|
||||
(j + 2) * sizeof(struct berval *) );
|
||||
}
|
||||
*bv = (struct berval **) LBER_REALLOC( *bv,
|
||||
(j + 2) * sizeof(struct berval *) );
|
||||
|
||||
rc = ber_get_stringal( ber, &((*bv)[j]) );
|
||||
j++;
|
||||
}
|
||||
@ -665,7 +657,7 @@ va_dcl
|
||||
case 'a': /* octet string - allocate storage as needed */
|
||||
ss = va_arg( ap, char ** );
|
||||
if ( *ss ) {
|
||||
free( *ss );
|
||||
LBER_FREE( *ss );
|
||||
*ss = NULL;
|
||||
}
|
||||
break;
|
||||
@ -690,7 +682,7 @@ va_dcl
|
||||
case 'o': /* octet string in a supplied berval */
|
||||
bval = va_arg( ap, struct berval * );
|
||||
if ( bval->bv_val != NULL ) {
|
||||
free( bval->bv_val );
|
||||
LBER_FREE( bval->bv_val );
|
||||
bval->bv_val = NULL;
|
||||
}
|
||||
bval->bv_len = 0;
|
||||
@ -707,7 +699,7 @@ va_dcl
|
||||
case 'B': /* bit string - allocate storage as needed */
|
||||
ss = va_arg( ap, char ** );
|
||||
if ( *ss ) {
|
||||
free( *ss );
|
||||
LBER_FREE( *ss );
|
||||
*ss = NULL;
|
||||
}
|
||||
*(va_arg( ap, long * )) = 0; /* for length, in bits */
|
||||
@ -717,10 +709,10 @@ va_dcl
|
||||
sss = va_arg( ap, char *** );
|
||||
if ( *sss ) {
|
||||
for (j = 0; (*sss)[j]; j++) {
|
||||
free( (*sss)[j] );
|
||||
LBER_FREE( (*sss)[j] );
|
||||
(*sss)[j] = NULL;
|
||||
}
|
||||
free( *sss );
|
||||
LBER_FREE( *sss );
|
||||
*sss = NULL;
|
||||
}
|
||||
break;
|
||||
@ -759,8 +751,8 @@ ber_bvfree( struct berval *bv )
|
||||
assert(bv != NULL); /* bv damn better point to something */
|
||||
|
||||
if ( bv->bv_val != NULL )
|
||||
free( bv->bv_val );
|
||||
free( (char *) bv );
|
||||
LBER_FREE( bv->bv_val );
|
||||
LBER_FREE( (char *) bv );
|
||||
}
|
||||
|
||||
void
|
||||
@ -772,7 +764,7 @@ ber_bvecfree( struct berval **bv )
|
||||
|
||||
for ( i = 0; bv[i] != NULL; i++ )
|
||||
ber_bvfree( bv[i] );
|
||||
free( (char *) bv );
|
||||
LBER_FREE( (char *) bv );
|
||||
}
|
||||
|
||||
struct berval *
|
||||
@ -787,7 +779,7 @@ ber_bvdup(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( (new = (struct berval *) malloc( sizeof(struct berval) ))
|
||||
if ( (new = (struct berval *) LBER_MALLOC( sizeof(struct berval) ))
|
||||
== NULL ) {
|
||||
return( NULL );
|
||||
}
|
||||
@ -798,8 +790,8 @@ ber_bvdup(
|
||||
return ( new );
|
||||
}
|
||||
|
||||
if ( (new->bv_val = (char *) malloc( bv->bv_len + 1 )) == NULL ) {
|
||||
free( new );
|
||||
if ( (new->bv_val = (char *) LBER_MALLOC( bv->bv_len + 1 )) == NULL ) {
|
||||
LBER_FREE( new );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ ber_put_ostring(
|
||||
|
||||
#ifdef STR_TRANSLATION
|
||||
if ( free_str ) {
|
||||
free( str );
|
||||
LBER_FREE( str );
|
||||
}
|
||||
#endif /* STR_TRANSLATION */
|
||||
|
||||
@ -405,9 +405,11 @@ ber_start_seqorset( BerElement *ber, unsigned long tag )
|
||||
assert( ber != NULL );
|
||||
assert( BER_VALID( ber ) );
|
||||
|
||||
if ( (new = (Seqorset *) calloc( sizeof(Seqorset), 1 ))
|
||||
== NULLSEQORSET )
|
||||
new = (Seqorset *) LBER_CALLOC( 1, sizeof(Seqorset) );
|
||||
|
||||
if ( new == NULLSEQORSET )
|
||||
return( -1 );
|
||||
|
||||
new->sos_ber = ber;
|
||||
if ( ber->ber_sos == NULLSEQORSET )
|
||||
new->sos_first = ber->ber_ptr;
|
||||
@ -561,7 +563,7 @@ ber_put_seqorset( BerElement *ber )
|
||||
}
|
||||
|
||||
/* we're done with this seqorset, so free it up */
|
||||
free( (char *) (*sos) );
|
||||
LBER_FREE( (char *) (*sos) );
|
||||
*sos = next;
|
||||
|
||||
return( taglen + lenlen + len );
|
||||
|
@ -141,12 +141,12 @@ ber_realloc( BerElement *ber, unsigned long len )
|
||||
|
||||
oldbuf = ber->ber_buf;
|
||||
|
||||
ber->ber_buf = (char *) LBER_REALLOC( ber->ber_buf, total );
|
||||
|
||||
if ( ber->ber_buf == NULL ) {
|
||||
if ( (ber->ber_buf = (char *) malloc( (size_t)total )) == NULL )
|
||||
return( -1 );
|
||||
} else if ( (ber->ber_buf = (char *) realloc( ber->ber_buf,
|
||||
(size_t)total )) == NULL )
|
||||
ber->ber_buf = oldbuf;
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
ber->ber_end = ber->ber_buf + total;
|
||||
|
||||
@ -178,12 +178,12 @@ ber_free( BerElement *ber, int freebuf )
|
||||
assert( BER_VALID( ber ) );
|
||||
|
||||
if ( freebuf && ber->ber_buf != NULL )
|
||||
free( ber->ber_buf );
|
||||
LBER_FREE( ber->ber_buf );
|
||||
|
||||
ber->ber_buf = NULL;
|
||||
ber->ber_valid = LBER_UNINITIALIZED;
|
||||
|
||||
free( (char *) ber );
|
||||
LBER_FREE( (char *) ber );
|
||||
}
|
||||
|
||||
int
|
||||
@ -242,7 +242,7 @@ ber_alloc_t( int options )
|
||||
{
|
||||
BerElement *ber;
|
||||
|
||||
ber = (BerElement *) calloc( 1, sizeof(BerElement) );
|
||||
ber = (BerElement *) LBER_CALLOC( 1, sizeof(BerElement) );
|
||||
|
||||
if ( ber == NULLBER )
|
||||
return( NULLBER );
|
||||
@ -353,7 +353,7 @@ int ber_flatten(
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
if ( (bv = malloc( sizeof(struct berval))) == NULL ) {
|
||||
if ( (bv = LBER_MALLOC( sizeof(struct berval))) == NULL ) {
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ int ber_flatten(
|
||||
/* copy the berval */
|
||||
ptrdiff_t len = ber->ber_ptr - ber->ber_buf;
|
||||
|
||||
if ( (bv->bv_val = (char *) malloc( len + 1 )) == NULL ) {
|
||||
if ( (bv->bv_val = (char *) LBER_MALLOC( len + 1 )) == NULL ) {
|
||||
ber_bvfree( bv );
|
||||
return( -1 );
|
||||
}
|
||||
@ -554,7 +554,7 @@ fill_buffer:
|
||||
errno = ERANGE;
|
||||
return LBER_DEFAULT;
|
||||
}
|
||||
ber->ber_buf = (char *) malloc( ber->ber_len );
|
||||
ber->ber_buf = (char *) LBER_MALLOC( ber->ber_len );
|
||||
if (ber->ber_buf==NULL)
|
||||
return LBER_DEFAULT;
|
||||
ber->ber_rwptr = ber->ber_buf;
|
||||
|
@ -190,6 +190,13 @@ ber_log_sos_dump LDAP_P((
|
||||
int loglvl,
|
||||
const Seqorset *sos ));
|
||||
|
||||
/* memory.c */
|
||||
/* simple macros to realloc for now */
|
||||
#define LBER_MALLOC(s) (realloc(NULL,(s)))
|
||||
#define LBER_CALLOC(n,s) (calloc((n),(s)))
|
||||
#define LBER_REALLOC(p,s) (realloc((p),(s)))
|
||||
#define LBER_FREE(p) (realloc((p),(size_t)0))
|
||||
|
||||
/* sockbuf.c */
|
||||
|
||||
/* these should be ber_int*() functions */
|
||||
|
@ -151,6 +151,10 @@ SOURCE=..\..\include\lber_pvt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\memory.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\options.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
34
libraries/liblber/memory.c
Normal file
34
libraries/liblber/memory.c
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
|
||||
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
||||
*/
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lber-int.h"
|
||||
|
||||
void
|
||||
ber_memfree( void *p )
|
||||
{
|
||||
LBER_FREE( p );
|
||||
}
|
||||
|
||||
void *
|
||||
ber_memalloc( size_t s )
|
||||
{
|
||||
return LBER_MALLOC( s );
|
||||
}
|
||||
|
||||
void *
|
||||
ber_memcalloc( size_t n, size_t s )
|
||||
{
|
||||
return LBER_CALLOC( n, s );
|
||||
}
|
||||
|
||||
void *
|
||||
ber_memrealloc( void* p, size_t s )
|
||||
{
|
||||
return LBER_REALLOC( p, s );
|
||||
}
|
||||
|
@ -142,15 +142,15 @@ grow_buffer( Sockbuf_Buf * buf, long minsize )
|
||||
if ((buf->buf_base==NULL) || ((buf->buf_end==0) && (buf->buf_ptr==0))) {
|
||||
/* empty buffer */
|
||||
if (buf->buf_base!=NULL)
|
||||
free( buf->buf_base );
|
||||
LBER_FREE( buf->buf_base );
|
||||
assert( buf->buf_ptr==0 );
|
||||
assert( buf->buf_end==0 );
|
||||
buf->buf_base = malloc( minsize );
|
||||
buf->buf_base = LBER_MALLOC( minsize );
|
||||
if (buf->buf_base==NULL)
|
||||
return -1;
|
||||
} else {
|
||||
char *nb;
|
||||
nb = realloc( buf->buf_base, minsize );
|
||||
nb = LBER_REALLOC( buf->buf_base, minsize );
|
||||
if (nb==NULL)
|
||||
return -1;
|
||||
buf->buf_base = nb;
|
||||
@ -330,7 +330,7 @@ sockbuf_copy_out( Sockbuf *sb, char **buf, long len )
|
||||
|
||||
Sockbuf *ber_sockbuf_alloc( void )
|
||||
{
|
||||
Sockbuf *sb = calloc(1, sizeof(Sockbuf));
|
||||
Sockbuf *sb = LBER_CALLOC(1, sizeof(Sockbuf));
|
||||
|
||||
if( sb == NULL ) return NULL;
|
||||
|
||||
@ -354,7 +354,7 @@ void ber_sockbuf_free( Sockbuf *sb )
|
||||
assert(sb != NULL);
|
||||
assert( SOCKBUF_VALID( sb ) );
|
||||
ber_pvt_sb_destroy( sb );
|
||||
free(sb);
|
||||
LBER_FREE(sb);
|
||||
}
|
||||
|
||||
long
|
||||
@ -685,7 +685,7 @@ sockbuf_buf_destroy( Sockbuf_Buf *buf )
|
||||
assert( buf != NULL);
|
||||
|
||||
if (buf->buf_base)
|
||||
free( buf->buf_base );
|
||||
LBER_FREE( buf->buf_base );
|
||||
sockbuf_buf_init( buf );
|
||||
return 0;
|
||||
}
|
||||
@ -968,7 +968,7 @@ dgram_setup( Sockbuf *sb, void *arg )
|
||||
assert( sb != NULL);
|
||||
assert( SOCKBUF_VALID( sb ) );
|
||||
|
||||
sb->sb_iodata = malloc( sizeof( struct dgram_data ) );
|
||||
sb->sb_iodata = LBER_MALLOC( sizeof( struct dgram_data ) );
|
||||
if (sb->sb_iodata==NULL)
|
||||
return -1;
|
||||
sb->sb_read_ahead = 1; /* important since udp is packet based. */
|
||||
@ -981,7 +981,7 @@ dgram_release( Sockbuf *sb )
|
||||
assert( sb != NULL);
|
||||
assert( SOCKBUF_VALID( sb ) );
|
||||
|
||||
free( sb->sb_iodata );
|
||||
LBER_FREE( sb->sb_iodata );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,7 @@ do_abandon(
|
||||
{
|
||||
BerElement *ber;
|
||||
int i, err, sendabandon;
|
||||
unsigned long *old_abandon;
|
||||
Sockbuf *sb;
|
||||
LDAPRequest *lr;
|
||||
|
||||
@ -199,22 +200,23 @@ do_abandon(
|
||||
}
|
||||
}
|
||||
|
||||
if ( ld->ld_abandoned == NULL ) {
|
||||
if ( (ld->ld_abandoned = (int *) malloc( 2 * sizeof(int) ))
|
||||
== NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( ld->ld_errno );
|
||||
}
|
||||
i = 0;
|
||||
} else {
|
||||
for ( i = 0; ld->ld_abandoned[i] != -1; i++ )
|
||||
i = 0;
|
||||
if ( ld->ld_abandoned != NULL ) {
|
||||
for ( ; ld->ld_abandoned[i] != -1; i++ )
|
||||
; /* NULL */
|
||||
if ( (ld->ld_abandoned = (int *) realloc( (char *)
|
||||
ld->ld_abandoned, (i + 2) * sizeof(int) )) == NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( ld->ld_errno );
|
||||
}
|
||||
}
|
||||
|
||||
old_abandon = ld->ld_abandoned;
|
||||
|
||||
ld->ld_abandoned = (int *) LDAP_REALLOC( (char *)
|
||||
ld->ld_abandoned, (i + 2) * sizeof(int) );
|
||||
|
||||
if ( ld->ld_abandoned == NULL ) {
|
||||
ld->ld_abandoned = old_abandon;
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( ld->ld_errno );
|
||||
}
|
||||
|
||||
ld->ld_abandoned[i] = msgid;
|
||||
ld->ld_abandoned[i + 1] = -1;
|
||||
|
||||
|
@ -37,7 +37,7 @@ ldap_enable_cache( LDAP *ld, long timeout, long maxmem )
|
||||
{
|
||||
#ifndef LDAP_NOCACHE
|
||||
if ( ld->ld_cache == NULLLDCACHE ) {
|
||||
if (( ld->ld_cache = (LDAPCache *)malloc( sizeof( LDAPCache )))
|
||||
if (( ld->ld_cache = (LDAPCache *)LDAP_MALLOC( sizeof( LDAPCache )))
|
||||
== NULLLDCACHE ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( -1 );
|
||||
@ -86,7 +86,7 @@ ldap_destroy_cache( LDAP *ld )
|
||||
#ifndef LDAP_NOCACHE
|
||||
if ( ld->ld_cache != NULLLDCACHE ) {
|
||||
ldap_flush_cache( ld );
|
||||
free( (char *)ld->ld_cache );
|
||||
LDAP_FREE( (char *)ld->ld_cache );
|
||||
ld->ld_cache = NULLLDCACHE;
|
||||
}
|
||||
#endif
|
||||
@ -224,17 +224,17 @@ ldap_add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request
|
||||
return;
|
||||
}
|
||||
|
||||
if (( new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
|
||||
if (( new = (LDAPMessage *) LDAP_CALLOC( 1, sizeof(LDAPMessage) ))
|
||||
!= NULL ) {
|
||||
if (( new->lm_ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
|
||||
free( (char *)new );
|
||||
LDAP_FREE( (char *)new );
|
||||
return;
|
||||
}
|
||||
len = request->ber_ptr - request->ber_buf;
|
||||
if (( new->lm_ber->ber_buf = (char *) malloc( (size_t)len ))
|
||||
if (( new->lm_ber->ber_buf = (char *) ber_memalloc( (size_t)len ))
|
||||
== NULL ) {
|
||||
ber_free( new->lm_ber, 0 );
|
||||
free( (char *)new );
|
||||
LDAP_FREE( (char *)new );
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
@ -482,17 +482,17 @@ msg_dup( LDAPMessage *msg )
|
||||
LDAPMessage *new;
|
||||
long len;
|
||||
|
||||
if (( new = (LDAPMessage *)malloc( sizeof(LDAPMessage))) != NULL ) {
|
||||
if (( new = (LDAPMessage *)LDAP_MALLOC( sizeof(LDAPMessage))) != NULL ) {
|
||||
*new = *msg; /* struct copy */
|
||||
if (( new->lm_ber = ber_dup( msg->lm_ber )) == NULLBER ) {
|
||||
free( (char *)new );
|
||||
LDAP_FREE( (char *)new );
|
||||
return( NULLMSG );
|
||||
}
|
||||
len = msg->lm_ber->ber_end - msg->lm_ber->ber_buf;
|
||||
if (( new->lm_ber->ber_buf = (char *) malloc(
|
||||
if (( new->lm_ber->ber_buf = (char *) ber_memalloc(
|
||||
(size_t)len )) == NULL ) {
|
||||
ber_free( new->lm_ber, 0 );
|
||||
free( (char *)new );
|
||||
LDAP_FREE( (char *)new );
|
||||
return( NULLMSG );
|
||||
}
|
||||
SAFEMEMCPY( new->lm_ber->ber_buf, msg->lm_ber->ber_buf,
|
||||
@ -555,7 +555,7 @@ chain_contains_dn( LDAPMessage *msg, const char *dn )
|
||||
ber = *msg->lm_ber; /* struct copy */
|
||||
if ( ber_scanf( &ber, "{i{a", &msgid, &s ) != LBER_ERROR ) {
|
||||
rc = ( strcasecmp( dn, s ) == 0 ) ? 1 : 0;
|
||||
free( s );
|
||||
LDAP_FREE( s );
|
||||
if ( rc != 0 ) {
|
||||
return( rc );
|
||||
}
|
||||
@ -576,7 +576,7 @@ chain_contains_dn( LDAPMessage *msg, const char *dn )
|
||||
ber = *m->lm_ber; /* struct copy */
|
||||
if ( ber_scanf( &ber, "{a", &s ) != LBER_ERROR ) {
|
||||
rc = ( strcasecmp( dn, s ) == 0 ) ? 1 : 0;
|
||||
free( s );
|
||||
LDAP_FREE( s );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1034,7 +1034,7 @@ ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
|
||||
len = *buflenp;
|
||||
s = (Byte *) *bufp;
|
||||
|
||||
if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) {
|
||||
if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * len + 64 )) == NULL ) {
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
@ -1136,13 +1136,13 @@ ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
|
||||
len = o - oo;
|
||||
o = oo;
|
||||
|
||||
if ( (oo = (Byte *)realloc( o, len )) == NULL ) {
|
||||
free( o );
|
||||
if ( (oo = (Byte *)LDAP_REALLOC( o, len )) == NULL ) {
|
||||
LDAP_FREE( o );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
if ( free_input ) {
|
||||
free( *bufp );
|
||||
LDAP_FREE( *bufp );
|
||||
}
|
||||
*bufp = (char *) oo;
|
||||
*buflenp = len;
|
||||
@ -1571,7 +1571,7 @@ ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input )
|
||||
len = *buflenp;
|
||||
s = (Byte *) *bufp;
|
||||
|
||||
if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) {
|
||||
if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * len + 64 )) == NULL ) {
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
@ -1650,13 +1650,13 @@ ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input )
|
||||
len = o - oo;
|
||||
o = oo;
|
||||
|
||||
if ( (oo = (Byte *)realloc( o, len )) == NULL ) {
|
||||
free( o );
|
||||
if ( (oo = (Byte *)LDAP_REALLOC( o, len )) == NULL ) {
|
||||
LDAP_FREE( o );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
if ( free_input ) {
|
||||
free( *bufp );
|
||||
LDAP_FREE( *bufp );
|
||||
}
|
||||
*bufp = (char *) oo;
|
||||
*buflenp = len;
|
||||
@ -1694,7 +1694,7 @@ const Byte *s;
|
||||
Byte *o, *oo;
|
||||
Byte n;
|
||||
|
||||
if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) {
|
||||
if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * strlen( s ) + 64 )) == NULL ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
@ -1713,8 +1713,8 @@ const Byte *s;
|
||||
|
||||
o = oo;
|
||||
|
||||
if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) {
|
||||
free( o );
|
||||
if ( (oo = (Byte *)LDAP_REALLOC( o, strlen( o ) + 1 )) == NULL ) {
|
||||
LDAP_FREE( o );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
@ -1748,7 +1748,7 @@ Byte *s;
|
||||
Byte n;
|
||||
const Couple *cc;
|
||||
|
||||
if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) {
|
||||
if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * strlen( s ) + 64 )) == NULL ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
@ -1791,8 +1791,8 @@ Byte *s;
|
||||
|
||||
o = oo;
|
||||
|
||||
if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) {
|
||||
free( o );
|
||||
if ( (oo = (Byte *)LDAP_REALLOC( o, strlen( o ) + 1 )) == NULL ) {
|
||||
LDAP_FREE( o );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ cldap_open( char *host, int port )
|
||||
int local_h_errno;
|
||||
char *ha_buf=NULL;
|
||||
|
||||
#define DO_RETURN(x) if (ha_buf) free(ha_buf); return (x);
|
||||
#define DO_RETURN(x) if (ha_buf) LDAP_FREE(ha_buf); return (x);
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 );
|
||||
|
||||
@ -249,21 +249,17 @@ add_addr( LDAP *ld, struct sockaddr *sap )
|
||||
{
|
||||
struct sockaddr *newsap, **addrs;
|
||||
|
||||
if (( newsap = (struct sockaddr *)malloc( sizeof( struct sockaddr )))
|
||||
if (( newsap = (struct sockaddr *)LDAP_MALLOC( sizeof( struct sockaddr )))
|
||||
== NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
if ( ld->ld_cldapnaddr == 0 ) {
|
||||
addrs = (struct sockaddr **)malloc( sizeof(struct sockaddr *));
|
||||
} else {
|
||||
addrs = (struct sockaddr **)realloc( ld->ld_cldapaddrs,
|
||||
addrs = (struct sockaddr **)LDAP_REALLOC( ld->ld_cldapaddrs,
|
||||
( ld->ld_cldapnaddr + 1 ) * sizeof(struct sockaddr *));
|
||||
}
|
||||
|
||||
if ( addrs == NULL ) {
|
||||
free( newsap );
|
||||
LDAP_FREE( newsap );
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( -1 );
|
||||
}
|
||||
@ -339,13 +335,13 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
|
||||
logdn = NULL;
|
||||
|
||||
if ( ber_scanf( &ber, "ia", &id, &logdn ) == LBER_ERROR ) {
|
||||
free( ber.ber_buf ); /* gack! */
|
||||
LDAP_FREE( ber.ber_buf ); /* gack! */
|
||||
ret = LDAP_DECODING_ERROR;
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"cldap_result: ber_scanf returned LBER_ERROR (%d)\n",
|
||||
ret, 0, 0 );
|
||||
} else if ( id != msgid ) {
|
||||
free( ber.ber_buf ); /* gack! */
|
||||
LDAP_FREE( ber.ber_buf ); /* gack! */
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"cldap_result: looking for msgid %d; got %d\n",
|
||||
msgid, id, 0 );
|
||||
@ -367,13 +363,13 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
|
||||
}
|
||||
}
|
||||
ret = cldap_parsemsg( ld, msgid, &ber, res, base );
|
||||
free( ber.ber_buf ); /* gack! */
|
||||
LDAP_FREE( ber.ber_buf ); /* gack! */
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"cldap_result got result (%d)\n", ret, 0, 0 );
|
||||
}
|
||||
|
||||
if ( logdn != NULL ) {
|
||||
free( logdn );
|
||||
LDAP_FREE( logdn );
|
||||
}
|
||||
}
|
||||
|
||||
@ -423,7 +419,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
|
||||
for ( tag = ber_first_element( ber, &len, &cookie );
|
||||
tag != LBER_DEFAULT && rc != LDAP_SUCCESS;
|
||||
tag = ber_next_element( ber, &len, cookie )) {
|
||||
if (( ldm = (LDAPMessage *)calloc( 1, sizeof(LDAPMessage)))
|
||||
if (( ldm = (LDAPMessage *)LDAP_CALLOC( 1, sizeof(LDAPMessage)))
|
||||
== NULL || ( ldm->lm_ber = ldap_alloc_ber_with_options( ld ))
|
||||
== NULLBER ) {
|
||||
rc = LDAP_NO_MEMORY;
|
||||
@ -458,14 +454,14 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
|
||||
/*
|
||||
* substitute original searchbase for trailing '*'
|
||||
*/
|
||||
if (( p = (char *)malloc( slen + baselen )) == NULL ) {
|
||||
if (( p = (char *)LDAP_MALLOC( slen + baselen )) == NULL ) {
|
||||
rc = LDAP_NO_MEMORY;
|
||||
free( dn );
|
||||
LDAP_FREE( dn );
|
||||
break; /* return w/error */
|
||||
}
|
||||
strcpy( p, dn );
|
||||
strcpy( p + slen - 1, base );
|
||||
free( dn );
|
||||
LDAP_FREE( dn );
|
||||
dn = p;
|
||||
}
|
||||
|
||||
@ -473,7 +469,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
|
||||
bv->bv_len ) == -1 ) {
|
||||
break; /* return w/error */
|
||||
}
|
||||
free( dn );
|
||||
LDAP_FREE( dn );
|
||||
ber_bvfree( bv );
|
||||
bv = NULL;
|
||||
|
||||
@ -519,7 +515,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
|
||||
if ( ldm->lm_ber != NULLBER ) {
|
||||
ber_free( ldm->lm_ber, 1 );
|
||||
}
|
||||
free( ldm );
|
||||
LDAP_FREE( ldm );
|
||||
}
|
||||
if ( bv != NULL ) {
|
||||
ber_bvfree( bv );
|
||||
|
@ -131,7 +131,7 @@ int ldap_int_get_controls LDAP_P((
|
||||
|
||||
/* set through each element */
|
||||
nctrls = 0;
|
||||
*ctrls = malloc( 1 * sizeof(LDAPControl *) );
|
||||
*ctrls = LDAP_MALLOC( 1 * sizeof(LDAPControl *) );
|
||||
|
||||
if( *ctrls == NULL ) {
|
||||
return LDAP_NO_MEMORY;
|
||||
@ -146,19 +146,19 @@ int ldap_int_get_controls LDAP_P((
|
||||
LDAPControl *tctrl;
|
||||
LDAPControl **tctrls;
|
||||
|
||||
tctrl = calloc( 1, sizeof(LDAPControl) );
|
||||
tctrl = LDAP_CALLOC( 1, sizeof(LDAPControl) );
|
||||
|
||||
/* allocate pointer space for current controls (nctrls)
|
||||
* + this control + extra NULL
|
||||
*/
|
||||
tctrls = (tctrl == NULL) ? NULL :
|
||||
realloc(*ctrls, (nctrls+2) * sizeof(LDAPControl *));
|
||||
LDAP_REALLOC(*ctrls, (nctrls+2) * sizeof(LDAPControl *));
|
||||
|
||||
if( tctrls == NULL ) {
|
||||
/* one of the above allocation failed */
|
||||
|
||||
if( tctrl != NULL ) {
|
||||
free( tctrl );
|
||||
LDAP_FREE( tctrl );
|
||||
}
|
||||
|
||||
ldap_controls_free(*ctrls);
|
||||
@ -212,14 +212,14 @@ ldap_control_free( LDAPControl *c )
|
||||
{
|
||||
if ( c != NULL ) {
|
||||
if( c->ldctl_oid != NULL) {
|
||||
free( c->ldctl_oid );
|
||||
LDAP_FREE( c->ldctl_oid );
|
||||
}
|
||||
|
||||
if( c->ldctl_value.bv_val != NULL ) {
|
||||
free( c->ldctl_value.bv_val );
|
||||
LDAP_FREE( c->ldctl_value.bv_val );
|
||||
}
|
||||
|
||||
free( c );
|
||||
LDAP_FREE( c );
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ ldap_controls_free( LDAPControl **controls )
|
||||
ldap_control_free( c );
|
||||
}
|
||||
|
||||
free( controls );
|
||||
LDAP_FREE( controls );
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ LDAPControl **ldap_controls_dup( const LDAPControl **controls )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = (LDAPControl **) malloc( i * sizeof(LDAPControl *) );
|
||||
new = (LDAPControl **) LDAP_MALLOC( i * sizeof(LDAPControl *) );
|
||||
|
||||
if( new == NULL ) {
|
||||
/* memory allocation failure */
|
||||
@ -293,7 +293,7 @@ LDAPControl *ldap_control_dup( const LDAPControl *c )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = (LDAPControl *) malloc( sizeof(LDAPControl) );
|
||||
new = (LDAPControl *) LDAP_MALLOC( sizeof(LDAPControl) );
|
||||
|
||||
if( new == NULL ) {
|
||||
return NULL;
|
||||
@ -303,7 +303,7 @@ LDAPControl *ldap_control_dup( const LDAPControl *c )
|
||||
new->ldctl_oid = strdup( c->ldctl_oid );
|
||||
|
||||
if(new->ldctl_oid == NULL) {
|
||||
free( new );
|
||||
LDAP_FREE( new );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -312,13 +312,13 @@ LDAPControl *ldap_control_dup( const LDAPControl *c )
|
||||
}
|
||||
|
||||
if( c->ldctl_value.bv_len > 0 ) {
|
||||
new->ldctl_value.bv_val = (char *) malloc( c->ldctl_value.bv_len );
|
||||
new->ldctl_value.bv_val = (char *) LDAP_MALLOC( c->ldctl_value.bv_len );
|
||||
|
||||
if(new->ldctl_value.bv_val == NULL) {
|
||||
if(new->ldctl_oid != NULL) {
|
||||
free( new->ldctl_oid );
|
||||
LDAP_FREE( new->ldctl_oid );
|
||||
}
|
||||
free( new );
|
||||
LDAP_FREE( new );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp )
|
||||
return( LDAP_TMPL_ERR_FILE );
|
||||
}
|
||||
|
||||
if (( buf = malloc( (size_t)len )) == NULL ) {
|
||||
if (( buf = LDAP_MALLOC( (size_t)len )) == NULL ) {
|
||||
fclose( fp );
|
||||
return( LDAP_TMPL_ERR_MEM );
|
||||
}
|
||||
@ -126,12 +126,12 @@ ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp )
|
||||
fclose( fp );
|
||||
|
||||
if ( rlen != len && !eof ) { /* error: didn't get the whole file */
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
return( LDAP_TMPL_ERR_FILE );
|
||||
}
|
||||
|
||||
rc = ldap_init_templates_buf( buf, rlen, tmpllistp );
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
|
||||
return( rc );
|
||||
}
|
||||
@ -196,27 +196,27 @@ free_disptmpl( struct ldap_disptmpl *tmpl )
|
||||
{
|
||||
if ( tmpl != NULL ) {
|
||||
if ( tmpl->dt_name != NULL ) {
|
||||
free( tmpl->dt_name );
|
||||
LDAP_FREE( tmpl->dt_name );
|
||||
}
|
||||
|
||||
if ( tmpl->dt_pluralname != NULL ) {
|
||||
free( tmpl->dt_pluralname );
|
||||
LDAP_FREE( tmpl->dt_pluralname );
|
||||
}
|
||||
|
||||
if ( tmpl->dt_iconname != NULL ) {
|
||||
free( tmpl->dt_iconname );
|
||||
LDAP_FREE( tmpl->dt_iconname );
|
||||
}
|
||||
|
||||
if ( tmpl->dt_authattrname != NULL ) {
|
||||
free( tmpl->dt_authattrname );
|
||||
LDAP_FREE( tmpl->dt_authattrname );
|
||||
}
|
||||
|
||||
if ( tmpl->dt_defrdnattrname != NULL ) {
|
||||
free( tmpl->dt_defrdnattrname );
|
||||
LDAP_FREE( tmpl->dt_defrdnattrname );
|
||||
}
|
||||
|
||||
if ( tmpl->dt_defaddlocation != NULL ) {
|
||||
free( tmpl->dt_defaddlocation );
|
||||
LDAP_FREE( tmpl->dt_defaddlocation );
|
||||
}
|
||||
|
||||
if ( tmpl->dt_oclist != NULL ) {
|
||||
@ -225,7 +225,7 @@ free_disptmpl( struct ldap_disptmpl *tmpl )
|
||||
for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = nextocp ) {
|
||||
nextocp = ocp->oc_next;
|
||||
free_strarray( ocp->oc_objclasses );
|
||||
free( ocp );
|
||||
LDAP_FREE( ocp );
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,12 +235,12 @@ free_disptmpl( struct ldap_disptmpl *tmpl )
|
||||
for ( adp = tmpl->dt_adddeflist; adp != NULL; adp = nextadp ) {
|
||||
nextadp = adp->ad_next;
|
||||
if( adp->ad_attrname != NULL ) {
|
||||
free( adp->ad_attrname );
|
||||
LDAP_FREE( adp->ad_attrname );
|
||||
}
|
||||
if( adp->ad_value != NULL ) {
|
||||
free( adp->ad_value );
|
||||
LDAP_FREE( adp->ad_value );
|
||||
}
|
||||
free( adp );
|
||||
LDAP_FREE( adp );
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,20 +252,20 @@ free_disptmpl( struct ldap_disptmpl *tmpl )
|
||||
for ( colp = rowp; colp != NULL; colp = nextcolp ) {
|
||||
nextcolp = colp->ti_next_in_row;
|
||||
if ( colp->ti_attrname != NULL ) {
|
||||
free( colp->ti_attrname );
|
||||
LDAP_FREE( colp->ti_attrname );
|
||||
}
|
||||
if ( colp->ti_label != NULL ) {
|
||||
free( colp->ti_label );
|
||||
LDAP_FREE( colp->ti_label );
|
||||
}
|
||||
if ( colp->ti_args != NULL ) {
|
||||
free_strarray( colp->ti_args );
|
||||
}
|
||||
free( colp );
|
||||
LDAP_FREE( colp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free( tmpl );
|
||||
LDAP_FREE( tmpl );
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,13 +380,13 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
|
||||
attrcnt = 0;
|
||||
memerr = 0;
|
||||
|
||||
if (( attrs = (char **)malloc( sizeof( char * ))) == NULL ) {
|
||||
if (( attrs = (char **)LDAP_MALLOC( sizeof( char * ))) == NULL ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if ( includeattrs != NULL ) {
|
||||
for ( i = 0; !memerr && includeattrs[ i ] != NULL; ++i ) {
|
||||
if (( attrs = (char **)realloc( attrs, ( attrcnt + 2 ) *
|
||||
if (( attrs = (char **)LDAP_REALLOC( attrs, ( attrcnt + 2 ) *
|
||||
sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] =
|
||||
strdup( includeattrs[ i ] )) == NULL ) {
|
||||
memerr = 1;
|
||||
@ -413,7 +413,7 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
|
||||
}
|
||||
|
||||
if ( ticolp->ti_attrname != NULL ) {
|
||||
if (( attrs = (char **)realloc( attrs, ( attrcnt + 2 ) *
|
||||
if (( attrs = (char **)LDAP_REALLOC( attrs, ( attrcnt + 2 ) *
|
||||
sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] =
|
||||
strdup( ticolp->ti_attrname )) == NULL ) {
|
||||
memerr = 1;
|
||||
@ -427,11 +427,11 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
|
||||
if ( memerr || attrcnt == 0 ) {
|
||||
for ( i = 0; i < attrcnt; ++i ) {
|
||||
if ( attrs[ i ] != NULL ) {
|
||||
free( attrs[ i ] );
|
||||
LDAP_FREE( attrs[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
free( (char *)attrs );
|
||||
LDAP_FREE( (char *)attrs );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
@ -460,13 +460,13 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
return( tokcnt == 0 ? 0 : LDAP_TMPL_ERR_SYNTAX );
|
||||
}
|
||||
|
||||
if (( tmpl = (struct ldap_disptmpl *)calloc( 1,
|
||||
if (( tmpl = (struct ldap_disptmpl *)LDAP_CALLOC( 1,
|
||||
sizeof( struct ldap_disptmpl ))) == NULL ) {
|
||||
free_strarray( toks );
|
||||
return( LDAP_TMPL_ERR_MEM );
|
||||
}
|
||||
tmpl->dt_name = toks[ 0 ];
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* template plural name comes next
|
||||
@ -477,7 +477,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
return( LDAP_TMPL_ERR_SYNTAX );
|
||||
}
|
||||
tmpl->dt_pluralname = toks[ 0 ];
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* template icon name is next
|
||||
@ -488,7 +488,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
return( LDAP_TMPL_ERR_SYNTAX );
|
||||
}
|
||||
tmpl->dt_iconname = toks[ 0 ];
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* template options come next
|
||||
@ -511,7 +511,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
* object class list is next
|
||||
*/
|
||||
while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) {
|
||||
if (( ocp = (struct ldap_oclist *)calloc( 1,
|
||||
if (( ocp = (struct ldap_oclist *)LDAP_CALLOC( 1,
|
||||
sizeof( struct ldap_oclist ))) == NULL ) {
|
||||
free_strarray( toks );
|
||||
free_disptmpl( tmpl );
|
||||
@ -541,9 +541,9 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
if ( toks[ 0 ][ 0 ] != '\0' ) {
|
||||
tmpl->dt_authattrname = toks[ 0 ];
|
||||
} else {
|
||||
free( toks[ 0 ] );
|
||||
LDAP_FREE( toks[ 0 ] );
|
||||
}
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* read default attribute to use for RDN
|
||||
@ -554,7 +554,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
return( LDAP_TMPL_ERR_SYNTAX );
|
||||
}
|
||||
tmpl->dt_defrdnattrname = toks[ 0 ];
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* read default location for new entries
|
||||
@ -567,9 +567,9 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
if ( toks[ 0 ][ 0 ] != '\0' ) {
|
||||
tmpl->dt_defaddlocation = toks[ 0 ];
|
||||
} else {
|
||||
free( toks[ 0 ] );
|
||||
LDAP_FREE( toks[ 0 ] );
|
||||
}
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* read list of rules used to define default values for new entries
|
||||
@ -590,7 +590,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
return( LDAP_TMPL_ERR_SYNTAX );
|
||||
}
|
||||
|
||||
if (( adp = (struct ldap_adddeflist *)calloc( 1,
|
||||
if (( adp = (struct ldap_adddeflist *)LDAP_CALLOC( 1,
|
||||
sizeof( struct ldap_adddeflist ))) == NULL ) {
|
||||
free_strarray( toks );
|
||||
free_disptmpl( tmpl );
|
||||
@ -601,8 +601,8 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
if ( adsource == LDAP_ADSRC_CONSTANTVALUE ) {
|
||||
adp->ad_value = toks[ 2 ];
|
||||
}
|
||||
free( toks[ 0 ] );
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( toks[ 0 ] );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
if ( tmpl->dt_adddeflist == NULL ) {
|
||||
tmpl->dt_adddeflist = adp;
|
||||
@ -624,7 +624,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
return( LDAP_TMPL_ERR_SYNTAX );
|
||||
}
|
||||
|
||||
if (( ip = (struct ldap_tmplitem *)calloc( 1,
|
||||
if (( ip = (struct ldap_tmplitem *)LDAP_CALLOC( 1,
|
||||
sizeof( struct ldap_tmplitem ))) == NULL ) {
|
||||
free_strarray( toks );
|
||||
free_disptmpl( tmpl );
|
||||
@ -660,13 +660,13 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
return( LDAP_TMPL_ERR_SYNTAX );
|
||||
}
|
||||
|
||||
free( toks[ 0 ] );
|
||||
free( toks[ 1 ] );
|
||||
LDAP_FREE( toks[ 0 ] );
|
||||
LDAP_FREE( toks[ 1 ] );
|
||||
ip->ti_syntaxid = itemsynids[ i ];
|
||||
ip->ti_label = toks[ 2 ];
|
||||
if ( toks[ 3 ][ 0 ] == '\0' ) {
|
||||
ip->ti_attrname = NULL;
|
||||
free( toks[ 3 ] );
|
||||
LDAP_FREE( toks[ 3 ] );
|
||||
} else {
|
||||
ip->ti_attrname = toks[ 3 ];
|
||||
}
|
||||
@ -674,7 +674,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
for ( i = 0; toks[ i + 4 ] != NULL; ++i ) {
|
||||
;
|
||||
}
|
||||
if (( ip->ti_args = (char **) calloc( i + 1, sizeof( char * )))
|
||||
if (( ip->ti_args = (char **) LDAP_CALLOC( i + 1, sizeof( char * )))
|
||||
== NULL ) {
|
||||
free_disptmpl( tmpl );
|
||||
return( LDAP_TMPL_ERR_MEM );
|
||||
@ -683,7 +683,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
|
||||
ip->ti_args[ i ] = toks[ i + 4 ];
|
||||
}
|
||||
}
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
if ( tmpl->dt_items == NULL ) {
|
||||
tmpl->dt_items = rowp = ip;
|
||||
|
@ -51,18 +51,18 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp )
|
||||
return( rc );
|
||||
}
|
||||
|
||||
if (( toks = (char **)calloc( 1, sizeof( char * ))) == NULL ) {
|
||||
free( line );
|
||||
if (( toks = (char **)LDAP_CALLOC( 1, sizeof( char * ))) == NULL ) {
|
||||
LBER_FREE( line );
|
||||
return( -1 );
|
||||
}
|
||||
tokcnt = 0;
|
||||
|
||||
p = line;
|
||||
while (( token = next_token( &p )) != NULL ) {
|
||||
if (( toks = (char **)realloc( toks, ( tokcnt + 2 ) *
|
||||
if (( toks = (char **)LDAP_REALLOC( toks, ( tokcnt + 2 ) *
|
||||
sizeof( char * ))) == NULL ) {
|
||||
free( (char *)toks );
|
||||
free( line );
|
||||
LBER_FREE( (char *)toks );
|
||||
LBER_FREE( line );
|
||||
return( -1 );
|
||||
}
|
||||
toks[ tokcnt ] = token;
|
||||
@ -75,11 +75,11 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp )
|
||||
toks = NULL;
|
||||
}
|
||||
|
||||
free( line );
|
||||
LBER_FREE( line );
|
||||
|
||||
if ( tokcnt == 0 ) {
|
||||
if ( toks != NULL ) {
|
||||
free( (char *)toks );
|
||||
LBER_FREE( (char *)toks );
|
||||
}
|
||||
} else {
|
||||
*toksp = toks;
|
||||
@ -131,7 +131,7 @@ next_line( char **bufp, long *blenp, char **linep )
|
||||
return( 0 ); /* end of file */
|
||||
}
|
||||
|
||||
if (( line = malloc( p - linestart )) == NULL ) {
|
||||
if (( line = LDAP_MALLOC( p - linestart )) == NULL ) {
|
||||
*linep = NULL;
|
||||
return( -1 ); /* fatal error */
|
||||
}
|
||||
@ -203,8 +203,8 @@ free_strarray( char **sap )
|
||||
|
||||
if ( sap != NULL ) {
|
||||
for ( i = 0; sap[ i ] != NULL; ++i ) {
|
||||
free( sap[ i ] );
|
||||
LBER_FREE( sap[ i ] );
|
||||
}
|
||||
free( (char *)sap );
|
||||
LBER_FREE( (char *)sap );
|
||||
}
|
||||
}
|
||||
|
@ -155,11 +155,11 @@ ldap_result2error( LDAP *ld, LDAPMessage *r, int freeit )
|
||||
; /* NULL */
|
||||
|
||||
if ( ld->ld_error ) {
|
||||
free( ld->ld_error );
|
||||
LDAP_FREE( ld->ld_error );
|
||||
ld->ld_error = NULL;
|
||||
}
|
||||
if ( ld->ld_matched ) {
|
||||
free( ld->ld_matched );
|
||||
LDAP_FREE( ld->ld_matched );
|
||||
ld->ld_matched = NULL;
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,25 @@
|
||||
void
|
||||
ldap_memfree( void *p )
|
||||
{
|
||||
if(p != NULL) {
|
||||
free( p );
|
||||
}
|
||||
LDAP_FREE( p );
|
||||
}
|
||||
|
||||
void *
|
||||
ldap_memalloc( size_t s )
|
||||
{
|
||||
return LDAP_MALLOC( s );
|
||||
}
|
||||
|
||||
void *
|
||||
ldap_memcalloc( size_t n, size_t s )
|
||||
{
|
||||
return LDAP_CALLOC( n, s );
|
||||
}
|
||||
|
||||
void *
|
||||
ldap_memrealloc( void* p, size_t s )
|
||||
{
|
||||
return LDAP_REALLOC( p, s );
|
||||
}
|
||||
|
||||
void
|
||||
@ -41,31 +57,31 @@ ldap_getfilter_free( LDAPFiltDesc *lfdp )
|
||||
for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = nextflp ) {
|
||||
for ( fip = flp->lfl_ilist; fip != NULL; fip = nextfip ) {
|
||||
nextfip = fip->lfi_next;
|
||||
free( fip->lfi_filter );
|
||||
free( fip->lfi_desc );
|
||||
free( fip );
|
||||
LDAP_FREE( fip->lfi_filter );
|
||||
LDAP_FREE( fip->lfi_desc );
|
||||
LDAP_FREE( fip );
|
||||
}
|
||||
nextflp = flp->lfl_next;
|
||||
free( flp->lfl_pattern );
|
||||
free( flp->lfl_delims );
|
||||
free( flp->lfl_tag );
|
||||
free( flp );
|
||||
LDAP_FREE( flp->lfl_pattern );
|
||||
LDAP_FREE( flp->lfl_delims );
|
||||
LDAP_FREE( flp->lfl_tag );
|
||||
LDAP_FREE( flp );
|
||||
}
|
||||
|
||||
if ( lfdp->lfd_curvalcopy != NULL ) {
|
||||
free( lfdp->lfd_curvalcopy );
|
||||
LDAP_FREE( lfdp->lfd_curvalcopy );
|
||||
}
|
||||
if ( lfdp->lfd_curvalwords != NULL ) {
|
||||
free( lfdp->lfd_curvalwords );
|
||||
LDAP_FREE( lfdp->lfd_curvalwords );
|
||||
}
|
||||
if ( lfdp->lfd_filtprefix != NULL ) {
|
||||
free( lfdp->lfd_filtprefix );
|
||||
LDAP_FREE( lfdp->lfd_filtprefix );
|
||||
}
|
||||
if ( lfdp->lfd_filtsuffix != NULL ) {
|
||||
free( lfdp->lfd_filtsuffix );
|
||||
LDAP_FREE( lfdp->lfd_filtsuffix );
|
||||
}
|
||||
|
||||
free( lfdp );
|
||||
LDAP_FREE( lfdp );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -88,9 +104,9 @@ ldap_mods_free( LDAPMod **mods, int freemods )
|
||||
} else {
|
||||
ldap_value_free( mods[i]->mod_values );
|
||||
}
|
||||
free( (char *) mods[i] );
|
||||
LDAP_FREE( (char *) mods[i] );
|
||||
}
|
||||
|
||||
if ( freemods )
|
||||
free( (char *) mods );
|
||||
LDAP_FREE( (char *) mods );
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ ldap_friendly_name(
|
||||
}
|
||||
rewind( fp );
|
||||
|
||||
if ( (*map = (LDAPFriendlyMap *) malloc( (entries + 1) *
|
||||
if ( (*map = (LDAPFriendlyMap *) LDAP_MALLOC( (entries + 1) *
|
||||
sizeof(LDAPFriendlyMap) )) == NULL ) {
|
||||
fclose( fp );
|
||||
return( uname );
|
||||
@ -113,10 +113,10 @@ ldap_free_friendlymap( LDAPFriendlyMap **map )
|
||||
|
||||
while ( pF->lf_unfriendly )
|
||||
{
|
||||
free( pF->lf_unfriendly );
|
||||
free( pF->lf_friendly );
|
||||
LDAP_FREE( pF->lf_unfriendly );
|
||||
LDAP_FREE( pF->lf_friendly );
|
||||
pF++;
|
||||
}
|
||||
free( *map );
|
||||
LDAP_FREE( *map );
|
||||
*map = NULL;
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ ldap_explode_dns( LDAP_CONST char *dn_in )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if ( (rdns = (char **) malloc( maxcomps * sizeof(char *) )) == NULL ) {
|
||||
free( dn );
|
||||
if ( (rdns = (char **) LDAP_MALLOC( maxcomps * sizeof(char *) )) == NULL ) {
|
||||
LDAP_FREE( dn );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
@ -144,21 +144,21 @@ ldap_explode_dns( LDAP_CONST char *dn_in )
|
||||
{
|
||||
if ( ncomps == maxcomps ) {
|
||||
maxcomps *= 2;
|
||||
if ( (rdns = (char **) realloc( rdns, maxcomps *
|
||||
if ( (rdns = (char **) LDAP_REALLOC( rdns, maxcomps *
|
||||
sizeof(char *) )) == NULL )
|
||||
{
|
||||
free( dn );
|
||||
LDAP_FREE( dn );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
rdns[ncomps++] = strdup( s );
|
||||
}
|
||||
free(dn);
|
||||
LDAP_FREE(dn);
|
||||
|
||||
rdns[ncomps] = NULL;
|
||||
|
||||
/* trim rdns */
|
||||
rdns = (char **) realloc( rdns, (ncomps+1) * sizeof(char*) );
|
||||
rdns = (char **) LDAP_REALLOC( rdns, (ncomps+1) * sizeof(char*) );
|
||||
return( rdns );
|
||||
}
|
||||
|
||||
@ -218,11 +218,11 @@ explode_name( LDAP_CONST char *name, int notypes, int is_dn )
|
||||
if ( state == OUTQUOTE ) {
|
||||
++count;
|
||||
if ( parts == NULL ) {
|
||||
if (( parts = (char **)malloc( 8
|
||||
if (( parts = (char **)LDAP_MALLOC( 8
|
||||
* sizeof( char *))) == NULL )
|
||||
return( NULL );
|
||||
} else if ( count >= 8 ) {
|
||||
if (( parts = (char **)realloc( parts,
|
||||
if (( parts = (char **)LDAP_REALLOC( parts,
|
||||
(count+1) * sizeof( char *)))
|
||||
== NULL )
|
||||
return( NULL );
|
||||
@ -248,7 +248,7 @@ explode_name( LDAP_CONST char *name, int notypes, int is_dn )
|
||||
}
|
||||
|
||||
len = p - name;
|
||||
if (( parts[ count-1 ] = (char *)calloc( 1,
|
||||
if (( parts[ count-1 ] = (char *)LDAP_CALLOC( 1,
|
||||
len + 1 )) != NULL ) {
|
||||
SAFEMEMCPY( parts[ count-1 ], name,
|
||||
len );
|
||||
|
@ -48,10 +48,10 @@ ldap_getdxbyname( char *domain )
|
||||
/*
|
||||
* punt: return list conisting of the original domain name only
|
||||
*/
|
||||
if (( dxs = (char **)malloc( 2 * sizeof( char * ))) == NULL ||
|
||||
if (( dxs = (char **)LDAP_MALLOC( 2 * sizeof( char * ))) == NULL ||
|
||||
( dxs[ 0 ] = strdup( domain )) == NULL ) {
|
||||
if ( dxs != NULL ) {
|
||||
free( dxs );
|
||||
LDAP_FREE( dxs );
|
||||
}
|
||||
dxs = NULL;
|
||||
} else {
|
||||
@ -149,14 +149,10 @@ decode_answer( unsigned char *answer, int len )
|
||||
++r;
|
||||
--txt_len;
|
||||
}
|
||||
if ( dx_count == 0 ) {
|
||||
dxs = (char **)malloc( 2 * sizeof( char * ));
|
||||
} else {
|
||||
dxs = (char **)realloc( dxs,
|
||||
dxs = (char **)LDAP_REALLOC( dxs,
|
||||
( dx_count + 2 ) * sizeof( char * ));
|
||||
}
|
||||
if ( dxs == NULL || ( dxs[ dx_count ] =
|
||||
(char *)calloc( 1, txt_len + 1 )) == NULL ) {
|
||||
(char *)LDAP_CALLOC( 1, txt_len + 1 )) == NULL ) {
|
||||
err = NO_RECOVERY;
|
||||
continue;
|
||||
}
|
||||
|
@ -103,15 +103,15 @@ cleanup_and_return:
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
ld->ld_errno = rc;
|
||||
|
||||
if( ld->ld_matched != NULL )
|
||||
free( ld->ld_matched );
|
||||
if( ld->ld_matched != NULL ) {
|
||||
LDAP_FREE( ld->ld_matched );
|
||||
ld->ld_matched = NULL;
|
||||
}
|
||||
|
||||
ld->ld_matched = NULL;
|
||||
|
||||
if( ld->ld_error != NULL )
|
||||
free( ld->ld_error );
|
||||
|
||||
ld->ld_error = NULL;
|
||||
if( ld->ld_error != NULL ) {
|
||||
LDAP_FREE( ld->ld_error );
|
||||
ld->ld_error = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@ -59,7 +59,7 @@ ldap_init_getfilter( LDAP_CONST char *fname )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if (( buf = malloc( (size_t)len )) == NULL ) {
|
||||
if (( buf = LDAP_MALLOC( (size_t)len )) == NULL ) {
|
||||
fclose( fp );
|
||||
return( NULL );
|
||||
}
|
||||
@ -69,13 +69,13 @@ ldap_init_getfilter( LDAP_CONST char *fname )
|
||||
fclose( fp );
|
||||
|
||||
if ( rlen != len && !eof ) { /* error: didn't get the whole file */
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
|
||||
lfdp = ldap_init_getfilter_buf( buf, rlen );
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
|
||||
return( lfdp );
|
||||
}
|
||||
@ -92,7 +92,7 @@ ldap_init_getfilter_buf( char *buf, long buflen )
|
||||
int rc;
|
||||
regex_t re;
|
||||
|
||||
if (( lfdp = (LDAPFiltDesc *)calloc( 1, sizeof( LDAPFiltDesc))) == NULL ) {
|
||||
if (( lfdp = (LDAPFiltDesc *)LDAP_CALLOC( 1, sizeof( LDAPFiltDesc))) == NULL ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
@ -106,14 +106,14 @@ ldap_init_getfilter_buf( char *buf, long buflen )
|
||||
switch( tokcnt ) {
|
||||
case 1: /* tag line */
|
||||
if ( tag != NULL ) {
|
||||
free( tag );
|
||||
LDAP_FREE( tag );
|
||||
}
|
||||
tag = tok[ 0 ];
|
||||
free( tok );
|
||||
LDAP_FREE( tok );
|
||||
break;
|
||||
case 4:
|
||||
case 5: /* start of filter info. list */
|
||||
if (( nextflp = (LDAPFiltList *)calloc( 1, sizeof( LDAPFiltList )))
|
||||
if (( nextflp = (LDAPFiltList *)LDAP_CALLOC( 1, sizeof( LDAPFiltList )))
|
||||
== NULL ) {
|
||||
ldap_getfilter_free( lfdp );
|
||||
return( NULL );
|
||||
@ -152,7 +152,7 @@ ldap_init_getfilter_buf( char *buf, long buflen )
|
||||
case 2:
|
||||
case 3: /* filter, desc, and optional search scope */
|
||||
if ( nextflp != NULL ) { /* add to info list */
|
||||
if (( nextfip = (LDAPFiltInfo *)calloc( 1,
|
||||
if (( nextfip = (LDAPFiltInfo *)LDAP_CALLOC( 1,
|
||||
sizeof( LDAPFiltInfo ))) == NULL ) {
|
||||
ldap_getfilter_free( lfdp );
|
||||
free_strarray( tok );
|
||||
@ -180,14 +180,14 @@ ldap_init_getfilter_buf( char *buf, long buflen )
|
||||
errno = EINVAL;
|
||||
return( NULL );
|
||||
}
|
||||
free( tok[ 2 ] );
|
||||
LDAP_FREE( tok[ 2 ] );
|
||||
tok[ 2 ] = NULL;
|
||||
} else {
|
||||
nextfip->lfi_scope = LDAP_SCOPE_SUBTREE; /* default */
|
||||
}
|
||||
nextfip->lfi_isexact = ( strchr( tok[ 0 ], '*' ) == NULL &&
|
||||
strchr( tok[ 0 ], '~' ) == NULL );
|
||||
free( tok );
|
||||
LDAP_FREE( tok );
|
||||
}
|
||||
break;
|
||||
|
||||
@ -200,7 +200,7 @@ ldap_init_getfilter_buf( char *buf, long buflen )
|
||||
}
|
||||
|
||||
if ( tag != NULL ) {
|
||||
free( tag );
|
||||
LDAP_FREE( tag );
|
||||
}
|
||||
|
||||
return( lfdp );
|
||||
@ -211,12 +211,12 @@ void
|
||||
ldap_setfilteraffixes( LDAPFiltDesc *lfdp, LDAP_CONST char *prefix, LDAP_CONST char *suffix )
|
||||
{
|
||||
if ( lfdp->lfd_filtprefix != NULL ) {
|
||||
free( lfdp->lfd_filtprefix );
|
||||
LDAP_FREE( lfdp->lfd_filtprefix );
|
||||
}
|
||||
lfdp->lfd_filtprefix = ( prefix == NULL ) ? NULL : strdup( prefix );
|
||||
|
||||
if ( lfdp->lfd_filtsuffix != NULL ) {
|
||||
free( lfdp->lfd_filtsuffix );
|
||||
LDAP_FREE( lfdp->lfd_filtsuffix );
|
||||
}
|
||||
lfdp->lfd_filtsuffix = ( suffix == NULL ) ? NULL : strdup( suffix );
|
||||
}
|
||||
@ -233,8 +233,8 @@ ldap_getfirstfilter(
|
||||
regex_t re;
|
||||
|
||||
if ( lfdp->lfd_curvalcopy != NULL ) {
|
||||
free( lfdp->lfd_curvalcopy );
|
||||
free( lfdp->lfd_curvalwords );
|
||||
LDAP_FREE( lfdp->lfd_curvalcopy );
|
||||
LDAP_FREE( lfdp->lfd_curvalwords );
|
||||
}
|
||||
|
||||
lfdp->lfd_curval = value;
|
||||
@ -276,7 +276,7 @@ ldap_getfirstfilter(
|
||||
|
||||
if ( break_into_words( lfdp->lfd_curvalcopy, flp->lfl_delims,
|
||||
&lfdp->lfd_curvalwords ) < 0 ) {
|
||||
free( lfdp->lfd_curvalcopy );
|
||||
LDAP_FREE( lfdp->lfd_curvalcopy );
|
||||
lfdp->lfd_curvalcopy = NULL;
|
||||
return( NULL );
|
||||
}
|
||||
@ -421,7 +421,7 @@ break_into_words( /* LDAP_CONST */ char *str, LDAP_CONST char *delims, char ***w
|
||||
int count;
|
||||
char *tok_r;
|
||||
|
||||
if (( words = (char **)calloc( 1, sizeof( char * ))) == NULL ) {
|
||||
if (( words = (char **)LDAP_CALLOC( 1, sizeof( char * ))) == NULL ) {
|
||||
return( -1 );
|
||||
}
|
||||
count = 0;
|
||||
@ -429,7 +429,7 @@ break_into_words( /* LDAP_CONST */ char *str, LDAP_CONST char *delims, char ***w
|
||||
|
||||
word = ldap_pvt_strtok( str, delims, &tok_r );
|
||||
while ( word != NULL ) {
|
||||
if (( words = (char **)realloc( words,
|
||||
if (( words = (char **)LDAP_REALLOC( words,
|
||||
( count + 2 ) * sizeof( char * ))) == NULL ) {
|
||||
return( -1 );
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
|
||||
|
||||
/* break out on success, return out on error */
|
||||
while ( ! found ) {
|
||||
free(attr);
|
||||
LDAP_FREE(attr);
|
||||
attr = NULL;
|
||||
|
||||
if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) {
|
||||
@ -57,7 +57,7 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
|
||||
|
||||
}
|
||||
|
||||
free(attr);
|
||||
LDAP_FREE(attr);
|
||||
attr = NULL;
|
||||
|
||||
/*
|
||||
@ -96,7 +96,7 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
|
||||
|
||||
/* break out on success, return out on error */
|
||||
while ( ! found ) {
|
||||
free( attr );
|
||||
LDAP_FREE( attr );
|
||||
attr = NULL;
|
||||
|
||||
if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) {
|
||||
@ -108,7 +108,7 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
|
||||
break;
|
||||
}
|
||||
|
||||
free( attr );
|
||||
LDAP_FREE( attr );
|
||||
attr = NULL;
|
||||
|
||||
/*
|
||||
@ -152,8 +152,8 @@ ldap_value_free( char **vals )
|
||||
if ( vals == NULL )
|
||||
return;
|
||||
for ( i = 0; vals[i] != NULL; i++ )
|
||||
free( vals[i] );
|
||||
free( (char *) vals );
|
||||
LDAP_FREE( vals[i] );
|
||||
LDAP_FREE( (char *) vals );
|
||||
}
|
||||
|
||||
void
|
||||
@ -164,8 +164,8 @@ ldap_value_free_len( struct berval **vals )
|
||||
if ( vals == NULL )
|
||||
return;
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
free( vals[i]->bv_val );
|
||||
free( vals[i] );
|
||||
LDAP_FREE( vals[i]->bv_val );
|
||||
LDAP_FREE( vals[i] );
|
||||
}
|
||||
free( (char *) vals );
|
||||
LDAP_FREE( (char *) vals );
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ static void openldap_ldap_init_w_conf(const char *file)
|
||||
|
||||
case ATTR_STRING:
|
||||
p = &((char *) &gopts)[attrs[i].offset];
|
||||
if (* (char**) p != NULL) free(* (char**) p);
|
||||
if (* (char**) p != NULL) LDAP_FREE(* (char**) p);
|
||||
* (char**) p = strdup(opt);
|
||||
break;
|
||||
}
|
||||
@ -188,9 +188,9 @@ static void openldap_ldap_init_w_userconf(const char *file)
|
||||
home = getenv("HOME");
|
||||
|
||||
if (home != NULL) {
|
||||
path = malloc(strlen(home) + strlen(file) + 3);
|
||||
path = LDAP_MALLOC(strlen(home) + strlen(file) + 3);
|
||||
} else {
|
||||
path = malloc(strlen(file) + 3);
|
||||
path = LDAP_MALLOC(strlen(file) + 3);
|
||||
}
|
||||
|
||||
if(home != NULL && path != NULL) {
|
||||
@ -206,7 +206,7 @@ static void openldap_ldap_init_w_userconf(const char *file)
|
||||
}
|
||||
|
||||
if(path != NULL) {
|
||||
free(path);
|
||||
LDAP_FREE(path);
|
||||
}
|
||||
|
||||
/* try file */
|
||||
@ -272,7 +272,7 @@ static void openldap_ldap_init_w_env(const char *prefix)
|
||||
|
||||
case ATTR_STRING:
|
||||
p = &((char *) &gopts)[attrs[i].offset];
|
||||
if (* (char**) p != NULL) free(* (char**) p);
|
||||
if (* (char**) p != NULL) LDAP_FREE(* (char**) p);
|
||||
if (*value == '\0') {
|
||||
* (char**) p = NULL;
|
||||
} else {
|
||||
|
@ -69,7 +69,7 @@ ldap_kerberos_bind1( LDAP *ld, LDAP_CONST char *dn )
|
||||
|
||||
/* create a message to send */
|
||||
if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
|
||||
free( cred );
|
||||
LDAP_FREE( cred );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
@ -91,13 +91,13 @@ ldap_kerberos_bind1( LDAP *ld, LDAP_CONST char *dn )
|
||||
#endif /* STR_TRANSLATION */
|
||||
|
||||
if ( rc == -1 ) {
|
||||
free( cred );
|
||||
LDAP_FREE( cred );
|
||||
ber_free( ber, 1 );
|
||||
ld->ld_errno = LDAP_ENCODING_ERROR;
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
free( cred );
|
||||
LDAP_FREE( cred );
|
||||
|
||||
#ifndef LDAP_NOCACHE
|
||||
if ( ld->ld_cache != NULL ) {
|
||||
@ -162,7 +162,7 @@ ldap_kerberos_bind2( LDAP *ld, LDAP_CONST char *dn )
|
||||
|
||||
/* create a message to send */
|
||||
if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
|
||||
free( cred );
|
||||
LDAP_FREE( cred );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ ldap_kerberos_bind2( LDAP *ld, LDAP_CONST char *dn )
|
||||
}
|
||||
#endif /* STR_TRANSLATION */
|
||||
|
||||
free( cred );
|
||||
LDAP_FREE( cred );
|
||||
|
||||
if ( rc == -1 ) {
|
||||
ber_free( ber, 1 );
|
||||
@ -273,7 +273,7 @@ ldap_get_kerberosv4_credentials(
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if ( ( cred = malloc( ktxt.length )) == NULL ) {
|
||||
if ( ( cred = LDAP_MALLOC( ktxt.length )) == NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( NULL );
|
||||
}
|
||||
|
@ -263,6 +263,13 @@ extern struct ldapoptions ldap_int_global_options;
|
||||
void ldap_int_initialize LDAP_P((void));
|
||||
|
||||
|
||||
/* memory.c */
|
||||
/* simple macros to realloc for now */
|
||||
#define LDAP_MALLOC(s) (LBER_MALLOC((s)))
|
||||
#define LDAP_CALLOC(n,s) (LBER_CALLOC((n),(s)))
|
||||
#define LDAP_REALLOC(p,s) (LBER_REALLOC((p),(s)))
|
||||
#define LDAP_FREE(p) (LBER_FREE((p)))
|
||||
|
||||
/*
|
||||
* in unit-int.c
|
||||
*/
|
||||
@ -391,7 +398,9 @@ BerElement *ldap_build_search_req LDAP_P((
|
||||
/*
|
||||
* in strdup.c
|
||||
*/
|
||||
char *ldap_strdup LDAP_P(( const char * ));
|
||||
char *ldap_pvt_strdup LDAP_P(( const char * ));
|
||||
#undef strdup
|
||||
#define strdup ldap_pvt_strdup
|
||||
|
||||
/*
|
||||
* in unbind.c
|
||||
|
@ -47,18 +47,18 @@ ldap_open( LDAP_CONST char *host, int port )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) ==
|
||||
if (( srv = (LDAPServer *)LDAP_CALLOC( 1, sizeof( LDAPServer ))) ==
|
||||
NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
|
||||
strdup( ld->ld_defhost )) == NULL )) {
|
||||
if(srv != NULL) free( (char*) srv );
|
||||
if(srv != NULL) LDAP_FREE( (char*) srv );
|
||||
ldap_ld_free( ld, 0, NULL, NULL );
|
||||
return( NULL );
|
||||
}
|
||||
srv->lsrv_port = ld->ld_defport;
|
||||
|
||||
if (( ld->ld_defconn = ldap_new_connection( ld, &srv, 1,1,0 )) == NULL ) {
|
||||
if ( ld->ld_defhost != NULL ) free( srv->lsrv_host );
|
||||
free( (char *)srv );
|
||||
if ( ld->ld_defhost != NULL ) LDAP_FREE( srv->lsrv_host );
|
||||
LDAP_FREE( (char *)srv );
|
||||
ldap_ld_free( ld, 0, NULL, NULL );
|
||||
return( NULL );
|
||||
}
|
||||
@ -129,7 +129,7 @@ ldap_init( LDAP_CONST char *defhost, int defport )
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( (ld = (LDAP *) calloc( 1, sizeof(LDAP) )) == NULL ) {
|
||||
if ( (ld = (LDAP *) LDAP_CALLOC( 1, sizeof(LDAP) )) == NULL ) {
|
||||
WSACleanup( );
|
||||
return( NULL );
|
||||
}
|
||||
@ -154,7 +154,7 @@ ldap_init( LDAP_CONST char *defhost, int defport )
|
||||
}
|
||||
|
||||
if ( ld->ld_options.ldo_defhost == NULL ) {
|
||||
free( (char*)ld );
|
||||
LDAP_FREE( (char*)ld );
|
||||
WSACleanup( );
|
||||
return( NULL );
|
||||
}
|
||||
@ -165,11 +165,11 @@ ldap_init( LDAP_CONST char *defhost, int defport )
|
||||
}
|
||||
|
||||
if (( ld->ld_selectinfo = ldap_new_select_info()) == NULL ) {
|
||||
free( (char*) ld->ld_options.ldo_defhost );
|
||||
LDAP_FREE( (char*) ld->ld_options.ldo_defhost );
|
||||
if ( ld->ld_options.ldo_defbase == NULL ) {
|
||||
free( (char*) ld->ld_options.ldo_defbase );
|
||||
LDAP_FREE( (char*) ld->ld_options.ldo_defbase );
|
||||
}
|
||||
free( (char*) ld );
|
||||
LDAP_FREE( (char*) ld );
|
||||
WSACleanup( );
|
||||
return( NULL );
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ ldap_get_option(
|
||||
info->ldapai_extensions = NULL;
|
||||
} else {
|
||||
int i;
|
||||
info->ldapai_extensions = malloc(sizeof(char *) *
|
||||
info->ldapai_extensions = LDAP_MALLOC(sizeof(char *) *
|
||||
sizeof(features)/sizeof(LDAPAPIFeatureInfo));
|
||||
|
||||
for(i=0; features[i].ldapaif_name != NULL; i++) {
|
||||
@ -410,7 +410,7 @@ ldap_set_option(
|
||||
char* host = (char *) invalue;
|
||||
|
||||
if(lo->ldo_defhost != NULL) {
|
||||
free(lo->ldo_defhost);
|
||||
LDAP_FREE(lo->ldo_defhost);
|
||||
lo->ldo_defhost = NULL;
|
||||
}
|
||||
|
||||
@ -456,7 +456,7 @@ ldap_set_option(
|
||||
}
|
||||
|
||||
if( ld->ld_error ) {
|
||||
free(ld->ld_error);
|
||||
LDAP_FREE(ld->ld_error);
|
||||
}
|
||||
|
||||
ld->ld_error = strdup(err);
|
||||
|
@ -55,7 +55,7 @@ ldap_connect_to_host( Sockbuf *sb, const char *host, unsigned long address,
|
||||
struct hostent he_buf;
|
||||
int local_h_errno;
|
||||
char *ha_buf=NULL;
|
||||
#define DO_RETURN(x) if (ha_buf) free(ha_buf); return (x);
|
||||
#define DO_RETURN(x) if (ha_buf) LDAP_FREE(ha_buf); return (x);
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "ldap_connect_to_host: %s:%d\n",
|
||||
( host == NULL ) ? "(by address)" : host, (int) ntohs( (short) port ), 0 );
|
||||
@ -176,7 +176,7 @@ ldap_host_connected_to( Sockbuf *sb )
|
||||
struct hostent he_buf;
|
||||
int local_h_errno;
|
||||
char *ha_buf=NULL;
|
||||
#define DO_RETURN(x) if (ha_buf) free(ha_buf); return (x);
|
||||
#define DO_RETURN(x) if (ha_buf) LDAP_FREE(ha_buf); return (x);
|
||||
|
||||
(void)memset( (char *)&sin, 0, sizeof( struct sockaddr_in ));
|
||||
len = sizeof( sin );
|
||||
@ -282,7 +282,7 @@ ldap_new_select_info( void )
|
||||
{
|
||||
struct selectinfo *sip;
|
||||
|
||||
if (( sip = (struct selectinfo *)calloc( 1,
|
||||
if (( sip = (struct selectinfo *)LDAP_CALLOC( 1,
|
||||
sizeof( struct selectinfo ))) != NULL ) {
|
||||
FD_ZERO( &sip->si_readfds );
|
||||
FD_ZERO( &sip->si_writefds );
|
||||
@ -295,7 +295,7 @@ ldap_new_select_info( void )
|
||||
void
|
||||
ldap_free_select_info( void *sip )
|
||||
{
|
||||
free( sip );
|
||||
LDAP_FREE( sip );
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,15 +136,15 @@ free_and_return:
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
ld->ld_errno = rc;
|
||||
|
||||
if( ld->ld_matched != NULL )
|
||||
free( ld->ld_matched );
|
||||
if( ld->ld_matched != NULL ) {
|
||||
LDAP_FREE( ld->ld_matched );
|
||||
ld->ld_matched = NULL;
|
||||
}
|
||||
|
||||
ld->ld_matched = NULL;
|
||||
|
||||
if( ld->ld_error != NULL )
|
||||
free( ld->ld_error );
|
||||
|
||||
ld->ld_error = NULL;
|
||||
if( ld->ld_error != NULL ) {
|
||||
LDAP_FREE( ld->ld_error );
|
||||
ld->ld_error = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@ -80,11 +80,11 @@ ldap_send_initial_request(
|
||||
if ( ! ber_pvt_sb_in_use(&ld->ld_sb ) ) {
|
||||
/* not connected yet */
|
||||
|
||||
if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) ==
|
||||
if (( srv = (LDAPServer *)LDAP_CALLOC( 1, sizeof( LDAPServer ))) ==
|
||||
NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
|
||||
strdup( ld->ld_defhost )) == NULL ))
|
||||
{
|
||||
if (srv != NULL) free( srv );
|
||||
if (srv != NULL) LDAP_FREE( srv );
|
||||
ber_free( ber, 1 );
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( -1 );
|
||||
@ -95,8 +95,8 @@ ldap_send_initial_request(
|
||||
if (( ld->ld_defconn = ldap_new_connection( ld, &srv, 1,1,0 ))
|
||||
== NULL )
|
||||
{
|
||||
if ( ld->ld_defhost != NULL ) free( srv->lsrv_host );
|
||||
free( (char *)srv );
|
||||
if ( ld->ld_defhost != NULL ) LDAP_FREE( srv->lsrv_host );
|
||||
LDAP_FREE( (char *)srv );
|
||||
ber_free( ber, 1 );
|
||||
ld->ld_errno = LDAP_SERVER_DOWN;
|
||||
return( -1 );
|
||||
@ -190,7 +190,7 @@ ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
|
||||
}
|
||||
|
||||
use_connection( ld, lc );
|
||||
if (( lr = (LDAPRequest *)calloc( 1, sizeof( LDAPRequest ))) ==
|
||||
if (( lr = (LDAPRequest *)LDAP_CALLOC( 1, sizeof( LDAPRequest ))) ==
|
||||
NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
ldap_free_connection( ld, lc, 0, 0 );
|
||||
@ -269,10 +269,10 @@ ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
|
||||
* make a new LDAP server connection
|
||||
* XXX open connection synchronously for now
|
||||
*/
|
||||
if (( lc = (LDAPConn *)calloc( 1, sizeof( LDAPConn ))) == NULL ||
|
||||
if (( lc = (LDAPConn *)LDAP_CALLOC( 1, sizeof( LDAPConn ))) == NULL ||
|
||||
( !use_ldsb && ( (sb = ber_sockbuf_alloc()) == NULL ))) {
|
||||
if ( lc != NULL ) {
|
||||
free( (char *)lc );
|
||||
LDAP_FREE( (char *)lc );
|
||||
}
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( NULL );
|
||||
@ -296,7 +296,7 @@ ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
|
||||
if ( !use_ldsb ) {
|
||||
ber_sockbuf_free( lc->lconn_sb );
|
||||
}
|
||||
free( (char *)lc );
|
||||
LDAP_FREE( (char *)lc );
|
||||
ld->ld_errno = LDAP_SERVER_DOWN;
|
||||
return( NULL );
|
||||
}
|
||||
@ -437,12 +437,12 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
|
||||
}
|
||||
free_servers( lc->lconn_server );
|
||||
if ( lc->lconn_krbinstance != NULL ) {
|
||||
free( lc->lconn_krbinstance );
|
||||
LDAP_FREE( lc->lconn_krbinstance );
|
||||
}
|
||||
if ( lc->lconn_sb != &ld->ld_sb ) {
|
||||
ber_sockbuf_free( lc->lconn_sb );
|
||||
}
|
||||
free( lc );
|
||||
LDAP_FREE( lc );
|
||||
Debug( LDAP_DEBUG_TRACE, "ldap_free_connection: actually freed\n",
|
||||
0, 0, 0 );
|
||||
} else {
|
||||
@ -556,14 +556,14 @@ ldap_free_request( LDAP *ld, LDAPRequest *lr )
|
||||
}
|
||||
|
||||
if ( lr->lr_res_error != NULL ) {
|
||||
free( lr->lr_res_error );
|
||||
LDAP_FREE( lr->lr_res_error );
|
||||
}
|
||||
|
||||
if ( lr->lr_res_matched != NULL ) {
|
||||
free( lr->lr_res_matched );
|
||||
LDAP_FREE( lr->lr_res_matched );
|
||||
}
|
||||
|
||||
free( lr );
|
||||
LDAP_FREE( lr );
|
||||
}
|
||||
|
||||
|
||||
@ -575,12 +575,12 @@ free_servers( LDAPServer *srvlist )
|
||||
while ( srvlist != NULL ) {
|
||||
nextsrv = srvlist->lsrv_next;
|
||||
if ( srvlist->lsrv_dn != NULL ) {
|
||||
free( srvlist->lsrv_dn );
|
||||
LDAP_FREE( srvlist->lsrv_dn );
|
||||
}
|
||||
if ( srvlist->lsrv_host != NULL ) {
|
||||
free( srvlist->lsrv_host );
|
||||
LDAP_FREE( srvlist->lsrv_host );
|
||||
}
|
||||
free( srvlist );
|
||||
LDAP_FREE( srvlist );
|
||||
srvlist = nextsrv;
|
||||
}
|
||||
}
|
||||
@ -693,7 +693,7 @@ ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
|
||||
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
|
||||
if ( ldapref ) {
|
||||
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
|
||||
if (( srv = (LDAPServer *)calloc( 1,
|
||||
if (( srv = (LDAPServer *)LDAP_CALLOC( 1,
|
||||
sizeof( LDAPServer ))) == NULL ) {
|
||||
ber_free( ber, 1 );
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
@ -701,7 +701,7 @@ ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
|
||||
}
|
||||
|
||||
if (( srv->lsrv_host = strdup( tmpref )) == NULL ) {
|
||||
free( (char *)srv );
|
||||
LDAP_FREE( (char *)srv );
|
||||
ber_free( ber, 1 );
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( -1 );
|
||||
@ -730,11 +730,11 @@ ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
|
||||
}
|
||||
|
||||
if ( !newdn && refdn != NULL ) {
|
||||
free( refdn );
|
||||
LDAP_FREE( refdn );
|
||||
}
|
||||
}
|
||||
|
||||
free( *errstrp );
|
||||
LDAP_FREE( *errstrp );
|
||||
*errstrp = unfollowed;
|
||||
|
||||
return(( rc == 0 ) ? count : rc );
|
||||
@ -748,11 +748,11 @@ ldap_append_referral( LDAP *ld, char **referralsp, char *s )
|
||||
|
||||
if ( *referralsp == NULL ) {
|
||||
first = 1;
|
||||
*referralsp = (char *)malloc( strlen( s ) + LDAP_REF_STR_LEN
|
||||
*referralsp = (char *)LDAP_MALLOC( strlen( s ) + LDAP_REF_STR_LEN
|
||||
+ 1 );
|
||||
} else {
|
||||
first = 0;
|
||||
*referralsp = (char *)realloc( *referralsp,
|
||||
*referralsp = (char *)LDAP_REALLOC( *referralsp,
|
||||
strlen( *referralsp ) + strlen( s ) + 2 );
|
||||
}
|
||||
|
||||
@ -822,7 +822,7 @@ re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp )
|
||||
if ( *dnp == NULL ) {
|
||||
*dnp = orig_dn;
|
||||
} else {
|
||||
free( orig_dn );
|
||||
LDAP_FREE( orig_dn );
|
||||
}
|
||||
|
||||
if ( tag == LDAP_REQ_BIND ) {
|
||||
@ -917,7 +917,7 @@ dn2servers( LDAP *ld, char *dn ) /* dn can also be a domain.... */
|
||||
}
|
||||
|
||||
if ( host != NULL ) { /* found a server we can use */
|
||||
if (( srv = (LDAPServer *)calloc( 1,
|
||||
if (( srv = (LDAPServer *)LDAP_CALLOC( 1,
|
||||
sizeof( LDAPServer ))) == NULL ) {
|
||||
free_servers( srvlist );
|
||||
srvlist = NULL;
|
||||
|
@ -433,7 +433,7 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
|
||||
}
|
||||
|
||||
/* make a new ldap message */
|
||||
if ( (new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
|
||||
if ( (new = (LDAPMessage *) LDAP_CALLOC( 1, sizeof(LDAPMessage) ))
|
||||
== NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( -1 );
|
||||
@ -567,13 +567,13 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )
|
||||
parentr->lr_res_errno == LDAP_SUCCESS ) {
|
||||
parentr->lr_res_errno = lr->lr_res_errno;
|
||||
if ( parentr->lr_res_error != NULL ) {
|
||||
free( parentr->lr_res_error );
|
||||
LDAP_FREE( parentr->lr_res_error );
|
||||
}
|
||||
parentr->lr_res_error = lr->lr_res_error;
|
||||
lr->lr_res_error = NULL;
|
||||
if ( LDAP_NAME_ERROR( lr->lr_res_errno )) {
|
||||
if ( parentr->lr_res_matched != NULL ) {
|
||||
free( parentr->lr_res_matched );
|
||||
LDAP_FREE( parentr->lr_res_matched );
|
||||
}
|
||||
parentr->lr_res_matched = lr->lr_res_matched;
|
||||
lr->lr_res_matched = NULL;
|
||||
@ -621,7 +621,7 @@ ldap_msgfree( LDAPMessage *lm )
|
||||
next = lm->lm_chain;
|
||||
type = lm->lm_msgtype;
|
||||
ber_free( lm->lm_ber, 1 );
|
||||
free( (char *) lm );
|
||||
LDAP_FREE( (char *) lm );
|
||||
}
|
||||
|
||||
return( type );
|
||||
|
@ -13,9 +13,10 @@
|
||||
|
||||
#include <ac/ctype.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
|
||||
#include "ldap-int.h"
|
||||
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
#include <ldap_schema.h>
|
||||
|
||||
/*
|
||||
@ -38,15 +39,15 @@ new_safe_string(int size)
|
||||
{
|
||||
safe_string * ss;
|
||||
|
||||
ss = malloc(sizeof(safe_string));
|
||||
ss = LDAP_MALLOC(sizeof(safe_string));
|
||||
if ( !ss )
|
||||
return(NULL);
|
||||
ss->size = size;
|
||||
ss->pos = 0;
|
||||
ss->val = malloc(size);
|
||||
ss->val = LDAP_MALLOC(size);
|
||||
ss->at_whsp = 0;
|
||||
if ( !ss->val ) {
|
||||
free(ss);
|
||||
LDAP_FREE(ss);
|
||||
return(NULL);
|
||||
}
|
||||
return ss;
|
||||
@ -84,10 +85,10 @@ append_to_safe_string(safe_string * ss, char * s)
|
||||
/* We always make sure there is at least one position available */
|
||||
if ( ss->pos + l >= ss->size-1 ) {
|
||||
ss->size *= 2;
|
||||
temp = realloc(ss->val, ss->size);
|
||||
temp = LDAP_REALLOC(ss->val, ss->size);
|
||||
if ( !temp ) {
|
||||
/* Trouble, out of memory */
|
||||
free(ss->val);
|
||||
LDAP_FREE(ss->val);
|
||||
return -1;
|
||||
}
|
||||
ss->val = temp;
|
||||
@ -414,10 +415,10 @@ charray_free( char **array )
|
||||
|
||||
for ( a = array; *a != NULL; a++ ) {
|
||||
if ( *a != NULL ) {
|
||||
free( *a );
|
||||
LDAP_FREE( *a );
|
||||
}
|
||||
}
|
||||
free( (char *) array );
|
||||
LDAP_FREE( (char *) array );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -491,7 +492,7 @@ get_token(char ** sp, char ** token_val)
|
||||
(*sp)++;
|
||||
if ( **sp == '\'' ) {
|
||||
q = *sp;
|
||||
res = malloc(q-p+1);
|
||||
res = LDAP_MALLOC(q-p+1);
|
||||
if ( !res ) {
|
||||
kind = TK_OUTOFMEM;
|
||||
} else {
|
||||
@ -510,7 +511,7 @@ get_token(char ** sp, char ** token_val)
|
||||
while ( !isspace(**sp) && **sp != '\0' )
|
||||
(*sp)++;
|
||||
q = *sp;
|
||||
res = malloc(q-p+1);
|
||||
res = LDAP_MALLOC(q-p+1);
|
||||
if ( !res ) {
|
||||
kind = TK_OUTOFMEM;
|
||||
} else {
|
||||
@ -567,7 +568,7 @@ parse_numericoid(char **sp, int *code)
|
||||
}
|
||||
/* At this point, *sp points at the char past the numericoid. Perfect. */
|
||||
len = *sp - start;
|
||||
res = malloc(len+1);
|
||||
res = LDAP_MALLOC(len+1);
|
||||
if (!res) {
|
||||
*code = LDAP_SCHERR_OUTOFMEM;
|
||||
return(NULL);
|
||||
@ -593,7 +594,7 @@ parse_qdescrs(char **sp, int *code)
|
||||
if ( kind == TK_LEFTPAREN ) {
|
||||
/* Let's presume there will be at least 2 entries */
|
||||
size = 3;
|
||||
res = calloc(3,sizeof(char *));
|
||||
res = LDAP_CALLOC(3,sizeof(char *));
|
||||
if ( !res ) {
|
||||
*code = LDAP_SCHERR_OUTOFMEM;
|
||||
return NULL;
|
||||
@ -607,7 +608,7 @@ parse_qdescrs(char **sp, int *code)
|
||||
if ( kind == TK_QDESCR ) {
|
||||
if ( pos == size-2 ) {
|
||||
size++;
|
||||
res1 = realloc(res,size*sizeof(char *));
|
||||
res1 = LDAP_REALLOC(res,size*sizeof(char *));
|
||||
if ( !res1 ) {
|
||||
charray_free(res);
|
||||
*code = LDAP_SCHERR_OUTOFMEM;
|
||||
@ -628,7 +629,7 @@ parse_qdescrs(char **sp, int *code)
|
||||
parse_whsp(sp);
|
||||
return(res);
|
||||
} else if ( kind == TK_QDESCR ) {
|
||||
res = calloc(2,sizeof(char *));
|
||||
res = LDAP_CALLOC(2,sizeof(char *));
|
||||
if ( !res ) {
|
||||
*code = LDAP_SCHERR_OUTOFMEM;
|
||||
return NULL;
|
||||
@ -711,7 +712,7 @@ parse_oids(char **sp, int *code)
|
||||
if ( kind == TK_LEFTPAREN ) {
|
||||
/* Let's presume there will be at least 2 entries */
|
||||
size = 3;
|
||||
res = calloc(3,sizeof(char *));
|
||||
res = LDAP_CALLOC(3,sizeof(char *));
|
||||
if ( !res ) {
|
||||
*code = LDAP_SCHERR_OUTOFMEM;
|
||||
return NULL;
|
||||
@ -738,7 +739,7 @@ parse_oids(char **sp, int *code)
|
||||
if ( kind == TK_BAREWORD ) {
|
||||
if ( pos == size-2 ) {
|
||||
size++;
|
||||
res1 = realloc(res,size*sizeof(char *));
|
||||
res1 = LDAP_REALLOC(res,size*sizeof(char *));
|
||||
if ( !res1 ) {
|
||||
charray_free(res);
|
||||
*code = LDAP_SCHERR_OUTOFMEM;
|
||||
@ -764,7 +765,7 @@ parse_oids(char **sp, int *code)
|
||||
parse_whsp(sp);
|
||||
return(res);
|
||||
} else if ( kind == TK_BAREWORD ) {
|
||||
res = calloc(2,sizeof(char *));
|
||||
res = LDAP_CALLOC(2,sizeof(char *));
|
||||
if ( !res ) {
|
||||
*code = LDAP_SCHERR_OUTOFMEM;
|
||||
return NULL;
|
||||
@ -814,7 +815,7 @@ ldap_str2attributetype( char * s, int * code, char ** errp )
|
||||
LDAP_ATTRIBUTE_TYPE * at;
|
||||
|
||||
*errp = s;
|
||||
at = calloc(1,sizeof(LDAP_ATTRIBUTE_TYPE));
|
||||
at = LDAP_CALLOC(1,sizeof(LDAP_ATTRIBUTE_TYPE));
|
||||
|
||||
if ( !at ) {
|
||||
*code = LDAP_SCHERR_OUTOFMEM;
|
||||
@ -1068,7 +1069,7 @@ ldap_str2objectclass( char * s, int * code, char ** errp )
|
||||
LDAP_OBJECT_CLASS * oc;
|
||||
|
||||
*errp = s;
|
||||
oc = calloc(1,sizeof(LDAP_OBJECT_CLASS));
|
||||
oc = LDAP_CALLOC(1,sizeof(LDAP_OBJECT_CLASS));
|
||||
|
||||
if ( !oc ) {
|
||||
*code = LDAP_SCHERR_OUTOFMEM;
|
||||
|
@ -270,7 +270,7 @@ ldap_build_search_req(
|
||||
|
||||
filter = strdup( filter_in );
|
||||
err = put_filter( ber, filter );
|
||||
free( filter );
|
||||
LDAP_FREE( filter );
|
||||
|
||||
if ( err == -1 ) {
|
||||
ld->ld_errno = LDAP_FILTER_ERROR;
|
||||
@ -478,10 +478,10 @@ put_filter( BerElement *ber, char *str )
|
||||
*d = '\0';
|
||||
}
|
||||
if ( put_simple_filter( ber, tmp ) == -1 ) {
|
||||
free( tmp );
|
||||
LDAP_FREE( tmp );
|
||||
return( -1 );
|
||||
}
|
||||
free( tmp );
|
||||
LDAP_FREE( tmp );
|
||||
*next++ = ')';
|
||||
str = next;
|
||||
parens--;
|
||||
@ -520,10 +520,10 @@ put_filter( BerElement *ber, char *str )
|
||||
*d = '\0';
|
||||
}
|
||||
if ( put_simple_filter( ber, tmp ) == -1 ) {
|
||||
free( tmp );
|
||||
LDAP_FREE( tmp );
|
||||
return( -1 );
|
||||
}
|
||||
free( tmp );
|
||||
LDAP_FREE( tmp );
|
||||
str = next;
|
||||
break;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ ldap_sort_entries(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( (et = (struct entrything *) malloc( count *
|
||||
if ( (et = (struct entrything *) LDAP_MALLOC( count *
|
||||
sizeof(struct entrything) )) == NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( -1 );
|
||||
@ -118,7 +118,7 @@ ldap_sort_entries(
|
||||
|
||||
dn = ldap_get_dn( ld, e );
|
||||
et[i].et_vals = ldap_explode_dn( dn, 1 );
|
||||
free( dn );
|
||||
LDAP_FREE( dn );
|
||||
} else {
|
||||
et[i].et_vals = ldap_get_values( ld, e, attr );
|
||||
}
|
||||
@ -137,7 +137,7 @@ ldap_sort_entries(
|
||||
ldap_value_free( et[i].et_vals );
|
||||
}
|
||||
*ep = last;
|
||||
free( (char *) et );
|
||||
LDAP_FREE( (char *) et );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp )
|
||||
return( LDAP_SEARCHPREF_ERR_FILE );
|
||||
}
|
||||
|
||||
if (( buf = malloc( (size_t)len )) == NULL ) {
|
||||
if (( buf = LDAP_MALLOC( (size_t)len )) == NULL ) {
|
||||
fclose( fp );
|
||||
return( LDAP_SEARCHPREF_ERR_MEM );
|
||||
}
|
||||
@ -86,12 +86,12 @@ ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp )
|
||||
fclose( fp );
|
||||
|
||||
if ( rlen != len && !eof ) { /* error: didn't get the whole file */
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
return( LDAP_SEARCHPREF_ERR_FILE );
|
||||
}
|
||||
|
||||
rc = ldap_init_searchprefs_buf( buf, rlen, solistp );
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
|
||||
return( rc );
|
||||
}
|
||||
@ -158,40 +158,40 @@ free_searchobj( struct ldap_searchobj *so )
|
||||
{
|
||||
if ( so != NULL ) {
|
||||
if ( so->so_objtypeprompt != NULL ) {
|
||||
free( so->so_objtypeprompt );
|
||||
LDAP_FREE( so->so_objtypeprompt );
|
||||
}
|
||||
if ( so->so_prompt != NULL ) {
|
||||
free( so->so_prompt );
|
||||
LDAP_FREE( so->so_prompt );
|
||||
}
|
||||
if ( so->so_filterprefix != NULL ) {
|
||||
free( so->so_filterprefix );
|
||||
LDAP_FREE( so->so_filterprefix );
|
||||
}
|
||||
if ( so->so_filtertag != NULL ) {
|
||||
free( so->so_filtertag );
|
||||
LDAP_FREE( so->so_filtertag );
|
||||
}
|
||||
if ( so->so_defaultselectattr != NULL ) {
|
||||
free( so->so_defaultselectattr );
|
||||
LDAP_FREE( so->so_defaultselectattr );
|
||||
}
|
||||
if ( so->so_defaultselecttext != NULL ) {
|
||||
free( so->so_defaultselecttext );
|
||||
LDAP_FREE( so->so_defaultselecttext );
|
||||
}
|
||||
if ( so->so_salist != NULL ) {
|
||||
struct ldap_searchattr *sa, *nextsa;
|
||||
for ( sa = so->so_salist; sa != NULL; sa = nextsa ) {
|
||||
nextsa = sa->sa_next;
|
||||
if ( sa->sa_attrlabel != NULL ) {
|
||||
free( sa->sa_attrlabel );
|
||||
LDAP_FREE( sa->sa_attrlabel );
|
||||
}
|
||||
if ( sa->sa_attr != NULL ) {
|
||||
free( sa->sa_attr );
|
||||
LDAP_FREE( sa->sa_attr );
|
||||
}
|
||||
if ( sa->sa_selectattr != NULL ) {
|
||||
free( sa->sa_selectattr );
|
||||
LDAP_FREE( sa->sa_selectattr );
|
||||
}
|
||||
if ( sa->sa_selecttext != NULL ) {
|
||||
free( sa->sa_selecttext );
|
||||
LDAP_FREE( sa->sa_selecttext );
|
||||
}
|
||||
free( sa );
|
||||
LDAP_FREE( sa );
|
||||
}
|
||||
}
|
||||
if ( so->so_smlist != NULL ) {
|
||||
@ -199,15 +199,15 @@ free_searchobj( struct ldap_searchobj *so )
|
||||
for ( sm = so->so_smlist; sm != NULL; sm = nextsm ) {
|
||||
nextsm = sm->sm_next;
|
||||
if ( sm->sm_matchprompt != NULL ) {
|
||||
free( sm->sm_matchprompt );
|
||||
LDAP_FREE( sm->sm_matchprompt );
|
||||
}
|
||||
if ( sm->sm_filter != NULL ) {
|
||||
free( sm->sm_filter );
|
||||
LDAP_FREE( sm->sm_filter );
|
||||
}
|
||||
free( sm );
|
||||
LDAP_FREE( sm );
|
||||
}
|
||||
}
|
||||
free( so );
|
||||
LDAP_FREE( so );
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,13 +248,13 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
|
||||
return( tokcnt == 0 ? 0 : LDAP_SEARCHPREF_ERR_SYNTAX );
|
||||
}
|
||||
|
||||
if (( so = (struct ldap_searchobj *)calloc( 1,
|
||||
if (( so = (struct ldap_searchobj *)LDAP_CALLOC( 1,
|
||||
sizeof( struct ldap_searchobj ))) == NULL ) {
|
||||
free_strarray( toks );
|
||||
return( LDAP_SEARCHPREF_ERR_MEM );
|
||||
}
|
||||
so->so_objtypeprompt = toks[ 0 ];
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* if this is post-version zero, options come next
|
||||
@ -284,7 +284,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
|
||||
return( LDAP_SEARCHPREF_ERR_SYNTAX );
|
||||
}
|
||||
so->so_prompt = toks[ 0 ];
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* Filter prefix for "More Choices" searching is next
|
||||
@ -295,7 +295,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
|
||||
return( LDAP_SEARCHPREF_ERR_SYNTAX );
|
||||
}
|
||||
so->so_filterprefix = toks[ 0 ];
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* "Fewer Choices" filter tag comes next
|
||||
@ -306,7 +306,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
|
||||
return( LDAP_SEARCHPREF_ERR_SYNTAX );
|
||||
}
|
||||
so->so_filtertag = toks[ 0 ];
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* Selection (disambiguation) attribute comes next
|
||||
@ -317,7 +317,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
|
||||
return( LDAP_SEARCHPREF_ERR_SYNTAX );
|
||||
}
|
||||
so->so_defaultselectattr = toks[ 0 ];
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* Label for selection (disambiguation) attribute
|
||||
@ -328,7 +328,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
|
||||
return( LDAP_SEARCHPREF_ERR_SYNTAX );
|
||||
}
|
||||
so->so_defaultselecttext = toks[ 0 ];
|
||||
free( (char *)toks );
|
||||
LDAP_FREE( (char *)toks );
|
||||
|
||||
/*
|
||||
* Search scope is next
|
||||
@ -361,7 +361,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
|
||||
ldap_free_searchprefs( so );
|
||||
return( LDAP_SEARCHPREF_ERR_SYNTAX );
|
||||
}
|
||||
if (( *sa = ( struct ldap_searchattr * ) calloc( 1,
|
||||
if (( *sa = ( struct ldap_searchattr * ) LDAP_CALLOC( 1,
|
||||
sizeof( struct ldap_searchattr ))) == NULL ) {
|
||||
free_strarray( toks );
|
||||
ldap_free_searchprefs( so );
|
||||
@ -378,8 +378,8 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
|
||||
( *sa )->sa_matchtypebitmap |= (1 << j);
|
||||
}
|
||||
}
|
||||
free( toks[ 2 ] );
|
||||
free( ( char * ) toks );
|
||||
LDAP_FREE( toks[ 2 ] );
|
||||
LDAP_FREE( ( char * ) toks );
|
||||
sa = &(( *sa )->sa_next);
|
||||
}
|
||||
*sa = NULL;
|
||||
@ -394,7 +394,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
|
||||
ldap_free_searchprefs( so );
|
||||
return( LDAP_SEARCHPREF_ERR_SYNTAX );
|
||||
}
|
||||
if (( *sm = ( struct ldap_searchmatch * ) calloc( 1,
|
||||
if (( *sm = ( struct ldap_searchmatch * ) LDAP_CALLOC( 1,
|
||||
sizeof( struct ldap_searchmatch ))) == NULL ) {
|
||||
free_strarray( toks );
|
||||
ldap_free_searchprefs( so );
|
||||
@ -402,7 +402,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
|
||||
}
|
||||
( *sm )->sm_matchprompt = toks[ 0 ];
|
||||
( *sm )->sm_filter = toks[ 1 ];
|
||||
free( ( char * ) toks );
|
||||
LDAP_FREE( ( char * ) toks );
|
||||
sm = &(( *sm )->sm_next );
|
||||
}
|
||||
*sm = NULL;
|
||||
|
@ -96,7 +96,7 @@ char *
|
||||
char *p;
|
||||
size_t len = strlen( s ) + 1;
|
||||
|
||||
if ( (p = (char *) malloc( len )) == NULL ) {
|
||||
if ( (p = (char *) LDAP_MALLOC( len )) == NULL ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
|
@ -149,9 +149,9 @@ do_entry2text(
|
||||
}
|
||||
|
||||
if ( buf == NULL ) {
|
||||
if (( buf = malloc( LDAP_DTMPL_BUFSIZ )) == NULL ) {
|
||||
if (( buf = LDAP_MALLOC( LDAP_DTMPL_BUFSIZ )) == NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
free( dn );
|
||||
LDAP_FREE( dn );
|
||||
return( ld->ld_errno );
|
||||
}
|
||||
freebuf = 1;
|
||||
@ -343,9 +343,9 @@ do_entry2text(
|
||||
(*writeproc)( writeparm, buf, strlen( buf ));
|
||||
}
|
||||
|
||||
free( dn );
|
||||
LDAP_FREE( dn );
|
||||
if ( freebuf ) {
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
}
|
||||
|
||||
return( err );
|
||||
@ -433,7 +433,7 @@ do_entry2text_search(
|
||||
timeout.tv_sec = SEARCH_TIMEOUT_SECS;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
if (( buf = malloc( LDAP_DTMPL_BUFSIZ )) == NULL ) {
|
||||
if (( buf = LDAP_MALLOC( LDAP_DTMPL_BUFSIZ )) == NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( ld->ld_errno );
|
||||
}
|
||||
@ -453,7 +453,7 @@ do_entry2text_search(
|
||||
|
||||
if ( dn == NULL ) {
|
||||
if (( dn = ldap_get_dn( ld, entry )) == NULL ) {
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
if ( freetmpls ) {
|
||||
ldap_free_templates( tmpllist );
|
||||
}
|
||||
@ -515,7 +515,7 @@ do_entry2text_search(
|
||||
fetchattrs, 0, &timeout, &ldmp );
|
||||
|
||||
if ( freedn ) {
|
||||
free( dn );
|
||||
LDAP_FREE( dn );
|
||||
}
|
||||
if ( fetchattrs != NULL ) {
|
||||
ldap_value_free( fetchattrs );
|
||||
@ -526,14 +526,14 @@ do_entry2text_search(
|
||||
if ( freetmpls ) {
|
||||
ldap_free_templates( tmpllist );
|
||||
}
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
return( ld->ld_errno );
|
||||
}
|
||||
|
||||
err = do_entry2text( ld, buf, base, entry, tmpl, defattrs, defvals,
|
||||
writeproc, writeparm, eol, rdncount, opts, urlprefix );
|
||||
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
if ( freetmpls ) {
|
||||
ldap_free_templates( tmpllist );
|
||||
}
|
||||
@ -627,7 +627,7 @@ do_vals2text(
|
||||
}
|
||||
|
||||
if ( buf == NULL ) {
|
||||
if (( buf = malloc( LDAP_DTMPL_BUFSIZ )) == NULL ) {
|
||||
if (( buf = LDAP_MALLOC( LDAP_DTMPL_BUFSIZ )) == NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( ld->ld_errno );
|
||||
}
|
||||
@ -753,7 +753,7 @@ do_vals2text(
|
||||
}
|
||||
|
||||
if ( freebuf ) {
|
||||
free( buf );
|
||||
LDAP_FREE( buf );
|
||||
}
|
||||
|
||||
return( LDAP_SUCCESS );
|
||||
@ -1083,7 +1083,7 @@ searchaction( LDAP *ld, char *buf, char *base, LDAPMessage *entry, char *dn,
|
||||
|
||||
if ( lderr == LDAP_SUCCESS || NONFATAL_LDAP_ERR( lderr )) {
|
||||
if (( count = ldap_count_entries( ld, ldmp )) > 0 ) {
|
||||
if (( members = (char **)malloc( (count + 1) * sizeof(char *)))
|
||||
if (( members = (char **)LDAP_MALLOC( (count + 1) * sizeof(char *)))
|
||||
== NULL ) {
|
||||
err = LDAP_NO_MEMORY;
|
||||
} else {
|
||||
|
@ -125,7 +125,7 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
|
||||
|
||||
if ( candidates == NULL ) {
|
||||
if ( prefix != NULL ) {
|
||||
if ( (dns = (char **) malloc( sizeof(char *)
|
||||
if ( (dns = (char **) LDAP_MALLOC( sizeof(char *)
|
||||
* 2 )) == NULL ) {
|
||||
return( ld->ld_errno = LDAP_NO_MEMORY );
|
||||
}
|
||||
@ -144,14 +144,14 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
|
||||
continue;
|
||||
|
||||
if ( dns == NULL ) {
|
||||
if ( (dns = (char **) malloc(
|
||||
if ( (dns = (char **) LDAP_MALLOC(
|
||||
sizeof(char *) * 8 )) == NULL ) {
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
return( LDAP_NO_MEMORY );
|
||||
}
|
||||
max = 8;
|
||||
} else if ( i >= max ) {
|
||||
if ( (dns = (char **) realloc( dns,
|
||||
if ( (dns = (char **) LDAP_REALLOC( dns,
|
||||
sizeof(char *) * 2 * max ))
|
||||
== NULL )
|
||||
{
|
||||
@ -264,7 +264,7 @@ ldap_ufn_search_ct(
|
||||
}
|
||||
for ( pcomp = 0; prefixcomp[pcomp] != NULL; pcomp++ )
|
||||
; /* NULL */
|
||||
if ( (pbuf = (char *) malloc( strlen( ld->ld_ufnprefix ) + 1 ))
|
||||
if ( (pbuf = (char *) LDAP_MALLOC( strlen( ld->ld_ufnprefix ) + 1 ))
|
||||
== NULL ) {
|
||||
ldap_value_free( ufncomp );
|
||||
ldap_value_free( prefixcomp );
|
||||
@ -293,7 +293,7 @@ ldap_ufn_search_ct(
|
||||
|
||||
ldap_value_free( ufncomp );
|
||||
ldap_value_free( prefixcomp );
|
||||
free( pbuf );
|
||||
LDAP_FREE( pbuf );
|
||||
|
||||
return( err );
|
||||
}
|
||||
@ -474,7 +474,7 @@ void
|
||||
ldap_ufn_setprefix( LDAP *ld, LDAP_CONST char *prefix )
|
||||
{
|
||||
if ( ld->ld_ufnprefix != NULL )
|
||||
free( ld->ld_ufnprefix );
|
||||
LDAP_FREE( ld->ld_ufnprefix );
|
||||
|
||||
ld->ld_ufnprefix = strdup( prefix );
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ ldap_ld_free(
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < ld->ld_cldapnaddr; ++i ) {
|
||||
free( ld->ld_cldapaddrs[ i ] );
|
||||
LDAP_FREE( ld->ld_cldapaddrs[ i ] );
|
||||
}
|
||||
free( ld->ld_cldapaddrs );
|
||||
LDAP_FREE( ld->ld_cldapaddrs );
|
||||
}
|
||||
|
||||
for ( lm = ld->ld_responses; lm != NULL; lm = next ) {
|
||||
@ -82,22 +82,22 @@ ldap_ld_free(
|
||||
#endif /* !LDAP_NOCACHE */
|
||||
|
||||
if ( ld->ld_error != NULL ) {
|
||||
free( ld->ld_error );
|
||||
LDAP_FREE( ld->ld_error );
|
||||
ld->ld_error = NULL;
|
||||
}
|
||||
|
||||
if ( ld->ld_matched != NULL ) {
|
||||
free( ld->ld_matched );
|
||||
LDAP_FREE( ld->ld_matched );
|
||||
ld->ld_matched = NULL;
|
||||
}
|
||||
|
||||
if ( ld->ld_host != NULL ) {
|
||||
free( ld->ld_host );
|
||||
LDAP_FREE( ld->ld_host );
|
||||
ld->ld_host = NULL;
|
||||
}
|
||||
|
||||
if ( ld->ld_ufnprefix != NULL ) {
|
||||
free( ld->ld_ufnprefix );
|
||||
LDAP_FREE( ld->ld_ufnprefix );
|
||||
ld->ld_ufnprefix = NULL;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ ldap_ld_free(
|
||||
}
|
||||
|
||||
if ( ld->ld_abandoned != NULL ) {
|
||||
free( ld->ld_abandoned );
|
||||
LDAP_FREE( ld->ld_abandoned );
|
||||
ld->ld_abandoned = NULL;
|
||||
}
|
||||
|
||||
@ -117,18 +117,18 @@ ldap_ld_free(
|
||||
}
|
||||
|
||||
if ( ld->ld_options.ldo_defbase != NULL ) {
|
||||
free( ld->ld_options.ldo_defbase );
|
||||
LDAP_FREE( ld->ld_options.ldo_defbase );
|
||||
ld->ld_options.ldo_defbase = NULL;
|
||||
}
|
||||
|
||||
if ( ld->ld_options.ldo_defhost != NULL ) {
|
||||
free( ld->ld_options.ldo_defhost );
|
||||
LDAP_FREE( ld->ld_options.ldo_defhost );
|
||||
ld->ld_options.ldo_defhost = NULL;
|
||||
}
|
||||
|
||||
ber_pvt_sb_destroy( &(ld->ld_sb) );
|
||||
|
||||
free( (char *) ld );
|
||||
LDAP_FREE( (char *) ld );
|
||||
|
||||
WSACleanup();
|
||||
|
||||
|
@ -121,10 +121,10 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
|
||||
}
|
||||
|
||||
/* allocate return struct */
|
||||
if (( ludp = (LDAPURLDesc *)calloc( 1, sizeof( LDAPURLDesc )))
|
||||
if (( ludp = (LDAPURLDesc *)LDAP_CALLOC( 1, sizeof( LDAPURLDesc )))
|
||||
== NULLLDAPURLDESC )
|
||||
{
|
||||
free( url );
|
||||
LDAP_FREE( url );
|
||||
return( LDAP_URL_ERR_MEM );
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
|
||||
}
|
||||
}
|
||||
|
||||
if (( ludp->lud_attrs = (char **)calloc( nattrs + 1,
|
||||
if (( ludp->lud_attrs = (char **)LDAP_CALLOC( nattrs + 1,
|
||||
sizeof( char * ))) == NULL ) {
|
||||
ldap_free_urldesc( ludp );
|
||||
return( LDAP_URL_ERR_MEM );
|
||||
@ -238,12 +238,12 @@ ldap_free_urldesc( LDAPURLDesc *ludp )
|
||||
{
|
||||
if ( ludp != NULLLDAPURLDESC ) {
|
||||
if ( ludp->lud_string != NULL ) {
|
||||
free( ludp->lud_string );
|
||||
LDAP_FREE( ludp->lud_string );
|
||||
}
|
||||
if ( ludp->lud_attrs != NULL ) {
|
||||
free( ludp->lud_attrs );
|
||||
LDAP_FREE( ludp->lud_attrs );
|
||||
}
|
||||
free( ludp );
|
||||
LDAP_FREE( ludp );
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,11 +273,11 @@ ldap_url_search( LDAP *ld, LDAP_CONST char *url, int attrsonly )
|
||||
err = 0;
|
||||
|
||||
if ( ludp->lud_host != NULL || ludp->lud_port != 0 ) {
|
||||
if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer )))
|
||||
if (( srv = (LDAPServer *)LDAP_CALLOC( 1, sizeof( LDAPServer )))
|
||||
== NULL || ( srv->lsrv_host = strdup( ludp->lud_host ==
|
||||
NULL ? ld->ld_defhost : ludp->lud_host )) == NULL ) {
|
||||
if ( srv != NULL ) {
|
||||
free( srv );
|
||||
LDAP_FREE( srv );
|
||||
}
|
||||
ld->ld_errno = LDAP_NO_MEMORY;
|
||||
err = -1;
|
||||
|
@ -360,7 +360,7 @@ static int copy_hostent( struct hostent *res, char **buf, struct hostent * src )
|
||||
static char *safe_realloc( char **buf, int len )
|
||||
{
|
||||
char *tmpbuf;
|
||||
tmpbuf = realloc( *buf, len );
|
||||
tmpbuf = LDAP_REALLOC( *buf, len );
|
||||
if (tmpbuf) {
|
||||
*buf=tmpbuf;
|
||||
}
|
||||
|
@ -288,6 +288,10 @@ SOURCE=..\libldap\sbind.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\libldap\schema.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\libldap\search.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -105,10 +105,6 @@ main( int argc, char **argv )
|
||||
}
|
||||
|
||||
|
||||
#define safe_realloc( ptr, size ) ( (ptr) == NULL ? malloc( size ) : \
|
||||
realloc( ptr, size ))
|
||||
|
||||
|
||||
static void
|
||||
addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
|
||||
{
|
||||
@ -130,9 +126,9 @@ addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
|
||||
}
|
||||
|
||||
if ( pmods == NULL || pmods[ i ] == NULL ) {
|
||||
if (( pmods = (LDAPMod **)safe_realloc( pmods, (i + 2) *
|
||||
if (( pmods = (LDAPMod **)realloc( pmods, (i + 2) *
|
||||
sizeof( LDAPMod * ))) == NULL ) {
|
||||
perror( "safe_realloc" );
|
||||
perror( "realloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
*pmodsp = pmods;
|
||||
@ -157,13 +153,13 @@ addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
|
||||
}
|
||||
}
|
||||
if (( pmods[ i ]->mod_bvalues =
|
||||
(struct berval **)safe_realloc( pmods[ i ]->mod_bvalues,
|
||||
(struct berval **)ber_realloc( pmods[ i ]->mod_bvalues,
|
||||
(j + 2) * sizeof( struct berval * ))) == NULL ) {
|
||||
perror( "safe_realloc" );
|
||||
perror( "ber_realloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
|
||||
if (( bvp = (struct berval *)malloc( sizeof( struct berval )))
|
||||
if (( bvp = (struct berval *)ber_malloc( sizeof( struct berval )))
|
||||
== NULL ) {
|
||||
perror( "malloc" );
|
||||
exit( 1 );
|
||||
|
Loading…
Reference in New Issue
Block a user