and ripple change through -lldap.
ber_bvdup LDAP_P((
LDAP_CONST struct berval *bv ));
+LDAP_F( char * )
+ber_strdup LDAP_P((
+ LDAP_CONST char * ));
+
LDAP_END_DECL
#endif /* _LBER_H */
#define LBER_INT_REALLOC(p,s) ber_memrealloc((p),(s))
#define LBER_INT_FREE(p) ber_memfree((p))
#define LBER_INT_VFREE(v) ber_memvfree((void**)(v))
+#define LBER_INT_STRDUP(s) ber_strdup((s))
#define LBER_MALLOC(s) ber_memalloc((s))
#define LBER_CALLOC(n,s) ber_memcalloc((n),(s))
#define LBER_REALLOC(p,s) ber_memrealloc((p),(s))
#define LBER_FREE(p) ber_memfree((p))
#define LBER_VFREE(v) ber_memvfree((void**)(v))
+#define LBER_STRDUP(s) ber_strdup((s))
/* sockbuf.c */
return( new );
}
+
+char *
+(ber_strdup)( LDAP_CONST char *s )
+{
+ char *p;
+ size_t len = strlen( s ) + 1;
+
+ if ( (p = (char *) LBER_MALLOC( len )) == NULL ) {
+ return( NULL );
+ }
+
+ SAFEMEMCPY( p, s, len );
+ return( p );
+}
\ No newline at end of file
}
if ( ld->ld_host == NULL ) {
- ld->ld_host = strdup( host );
+ ld->ld_host = LDAP_STRDUP( host );
}
}
} else {
}
if( c->ldctl_oid != NULL ) {
- new->ldctl_oid = strdup( c->ldctl_oid );
+ new->ldctl_oid = LDAP_STRDUP( c->ldctl_oid );
if(new->ldctl_oid == NULL) {
LDAP_FREE( new );
for ( i = 0; !memerr && includeattrs[ i ] != NULL; ++i ) {
if (( attrs = (char **)LDAP_REALLOC( attrs, ( attrcnt + 2 ) *
sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] =
- strdup( includeattrs[ i ] )) == NULL ) {
+ LDAP_STRDUP( includeattrs[ i ] )) == NULL ) {
memerr = 1;
} else {
attrs[ attrcnt ] = NULL;
if ( ticolp->ti_attrname != NULL ) {
if (( attrs = (char **)LDAP_REALLOC( attrs, ( attrcnt + 2 ) *
sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] =
- strdup( ticolp->ti_attrname )) == NULL ) {
+ LDAP_STRDUP( ticolp->ti_attrname )) == NULL ) {
memerr = 1;
} else {
attrs[ attrcnt ] = NULL;
return( NULL );
}
- return( strdup( tokstart ));
+ return( LDAP_STRDUP( tokstart ));
}
}
}
- (*map)[i].lf_unfriendly = strdup( buf );
- (*map)[i].lf_friendly = strdup( s );
+ (*map)[i].lf_unfriendly = LDAP_STRDUP( buf );
+ (*map)[i].lf_friendly = LDAP_STRDUP( s );
i++;
}
Debug( LDAP_DEBUG_TRACE, "ldap_dn2ufn\n", 0, 0, 0 );
if ( ldap_is_dns_dn( dn ) || ( p = strchr( dn, '=' )) == NULL )
- return( strdup( dn ) );
+ return( LDAP_STRDUP( dn ) );
- ufn = strdup( ++p );
+ ufn = LDAP_STRDUP( ++p );
#define INQUOTE 1
#define OUTQUOTE 2
int ncomps;
int maxcomps = 8;
- if ( (dn = strdup( dn_in )) == NULL ) {
+ if ( (dn = LDAP_STRDUP( dn_in )) == NULL ) {
return( NULL );
}
return NULL;
}
}
- rdns[ncomps++] = strdup( s );
+ rdns[ncomps++] = LDAP_STRDUP( s );
}
LDAP_FREE(dn);
* punt: return list conisting of the original domain name only
*/
if (( dxs = (char **)LDAP_MALLOC( 2 * sizeof( char * ))) == NULL ||
- ( dxs[ 0 ] = strdup( domain )) == NULL ) {
+ ( dxs[ 0 ] = LDAP_STRDUP( domain )) == NULL ) {
if ( dxs != NULL ) {
LDAP_FREE( dxs );
}
ldap_getfilter_free( lfdp );
return( NULL );
}
- nextflp->lfl_tag = strdup( tag );
+ nextflp->lfl_tag = LDAP_STRDUP( tag );
nextflp->lfl_pattern = tok[ 0 ];
if ( (rc = regcomp( &re, nextflp->lfl_pattern, 0 )) != 0 ) {
#ifdef LDAP_LIBUI
if ( lfdp->lfd_filtprefix != NULL ) {
LDAP_FREE( lfdp->lfd_filtprefix );
}
- lfdp->lfd_filtprefix = ( prefix == NULL ) ? NULL : strdup( prefix );
+ lfdp->lfd_filtprefix = ( prefix == NULL ) ? NULL : LDAP_STRDUP( prefix );
if ( lfdp->lfd_filtsuffix != NULL ) {
LDAP_FREE( lfdp->lfd_filtsuffix );
}
- lfdp->lfd_filtsuffix = ( suffix == NULL ) ? NULL : strdup( suffix );
+ lfdp->lfd_filtsuffix = ( suffix == NULL ) ? NULL : LDAP_STRDUP( suffix );
}
return( NULL );
}
- if (( lfdp->lfd_curvalcopy = strdup( value )) == NULL ) {
+ if (( lfdp->lfd_curvalcopy = LDAP_STRDUP( value )) == NULL ) {
return( NULL );
}
case ATTR_STRING:
p = &((char *) &gopts)[attrs[i].offset];
if (* (char**) p != NULL) LDAP_FREE(* (char**) p);
- * (char**) p = strdup(opt);
+ * (char**) p = LDAP_STRDUP(opt);
break;
}
}
if (*value == '\0') {
* (char**) p = NULL;
} else {
- * (char**) p = strdup(value);
+ * (char**) p = LDAP_STRDUP(value);
}
break;
}
gopts.ldo_debug = 0;
- gopts.ldo_defhost = strdup("localhost");
+ gopts.ldo_defhost = LDAP_STRDUP("localhost");
gopts.ldo_defport = LDAP_PORT;
gopts.ldo_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT;
#define LDAP_INT_REALLOC(p,s) (LBER_REALLOC((p),(s)))
#define LDAP_INT_FREE(p) (LBER_FREE((p)))
#define LDAP_INT_VFREE(v) (LBER_VFREE((void **)(v)))
+#define LDAP_INT_STRDUP(s) (LBER_STRDUP((s)))
-#ifndef LDAP_MALLOC
#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)))
#define LDAP_VFREE(v) (LBER_VFREE((void **)(v)))
-#endif
+#define LDAP_STRDUP(s) (LBER_STRDUP((s)))
/*
* in unit-int.c
/*
* in string.c
*/
-char *ldap_int_strdup LDAP_P(( const char * ));
-#undef strdup
-#define strdup ldap_int_strdup
+ /* see <ac/string.h> */
/*
* in unbind.c
if (( srv = (LDAPServer *)LDAP_CALLOC( 1, sizeof( LDAPServer ))) ==
NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
- strdup( ld->ld_defhost )) == NULL )) {
+ LDAP_STRDUP( ld->ld_defhost )) == NULL )) {
if(srv != NULL) LDAP_FREE( (char*) srv );
ldap_ld_free( ld, 0, NULL, NULL );
return( NULL );
ld->ld_options.ldo_cctrls = NULL;
if ( defhost != NULL ) {
- ld->ld_options.ldo_defhost = strdup( defhost );
+ ld->ld_options.ldo_defhost = LDAP_STRDUP( defhost );
} else {
- ld->ld_options.ldo_defhost = strdup(
+ ld->ld_options.ldo_defhost = LDAP_STRDUP(
ldap_int_global_options.ldo_defhost);
}
}
if ( ldap_int_global_options.ldo_defbase != NULL ) {
- ld->ld_options.ldo_defbase = strdup(
+ ld->ld_options.ldo_defbase = LDAP_STRDUP(
ldap_int_global_options.ldo_defbase);
}
for(i=0; features[i].ldapaif_name != NULL; i++) {
info->ldapai_extensions[i] =
- strdup(features[i].ldapaif_name);
+ LDAP_STRDUP(features[i].ldapaif_name);
}
info->ldapai_extensions[i] = NULL;
}
- info->ldapai_vendor_name = strdup(LDAP_VENDOR_NAME);
+ info->ldapai_vendor_name = LDAP_STRDUP(LDAP_VENDOR_NAME);
info->ldapai_vendor_version = LDAP_VENDOR_VERSION;
return LDAP_OPT_SUCCESS;
* we do.
*/
- * (char **) outvalue = strdup(lo->ldo_defhost);
+ * (char **) outvalue = LDAP_STRDUP(lo->ldo_defhost);
return LDAP_OPT_SUCCESS;
case LDAP_OPT_ERROR_NUMBER:
if( ld->ld_error == NULL ) {
* (char **) outvalue = NULL;
} else {
- * (char **) outvalue = strdup(ld->ld_error);
+ * (char **) outvalue = LDAP_STRDUP(ld->ld_error);
}
return LDAP_OPT_SUCCESS;
if( ld->ld_matched == NULL ) {
* (char **) outvalue = NULL;
} else {
- * (char **) outvalue = strdup(ld->ld_matched);
+ * (char **) outvalue = LDAP_STRDUP(ld->ld_matched);
}
return 0;
}
if(host != NULL) {
- lo->ldo_defhost = strdup(host);
+ lo->ldo_defhost = LDAP_STRDUP(host);
return LDAP_OPT_SUCCESS;
}
* must want global default returned
* to initial condition.
*/
- lo->ldo_defhost = strdup("localhost");
+ lo->ldo_defhost = LDAP_STRDUP("localhost");
} else {
/*
* must want the session default
* updated to the current global default
*/
- lo->ldo_defhost = strdup(
+ lo->ldo_defhost = LDAP_STRDUP(
ldap_int_global_options.ldo_defhost);
}
} return LDAP_OPT_SUCCESS;
LDAP_FREE(ld->ld_error);
}
- ld->ld_error = strdup(err);
+ ld->ld_error = LDAP_STRDUP(err);
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_API_FEATURE_INFO:
&hp,&local_h_errno ) ==0 ) && (hp != NULL) )
{
if ( hp->h_name != NULL ) {
- char *host = strdup( hp->h_name );
+ char *host = LDAP_STRDUP( hp->h_name );
DO_RETURN( host );
}
}
if (( srv = (LDAPServer *)LDAP_CALLOC( 1, sizeof( LDAPServer ))) ==
NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
- strdup( ld->ld_defhost )) == NULL ))
+ LDAP_STRDUP( ld->ld_defhost )) == NULL ))
{
if (srv != NULL) LDAP_FREE( srv );
ber_free( ber, 1 );
return( -1 );
}
- if (( srv->lsrv_host = strdup( tmpref )) == NULL ) {
+ if (( srv->lsrv_host = LDAP_STRDUP( tmpref )) == NULL ) {
LDAP_FREE( (char *)srv );
ber_free( ber, 1 );
ld->ld_errno = LDAP_NO_MEMORY;
prevsrv = srv;
/* copy in info. */
- if (( srv->lsrv_host = strdup( host )) == NULL ||
+ if (( srv->lsrv_host = LDAP_STRDUP( host )) == NULL ||
( server_dn != NULL && ( srv->lsrv_dn =
- strdup( server_dn )) == NULL )) {
+ LDAP_STRDUP( server_dn )) == NULL )) {
free_servers( srvlist );
srvlist = NULL;
break; /* exit loop & return */
print_whsp(ss);
print_literal(ss,")");
- retstring = strdup(safe_string_val(ss));
+ retstring = LDAP_STRDUP(safe_string_val(ss));
safe_string_free(ss);
return(retstring);
}
print_whsp(ss);
print_literal(ss,")");
- retstring = strdup(safe_string_val(ss));
+ retstring = LDAP_STRDUP(safe_string_val(ss));
safe_string_free(ss);
return(retstring);
}
print_whsp(ss);
print_literal(ss,")");
- retstring = strdup(safe_string_val(ss));
+ retstring = LDAP_STRDUP(safe_string_val(ss));
safe_string_free(ss);
return(retstring);
}
return( NULLBER );
}
- filter = strdup( filter_in );
+ filter = LDAP_STRDUP( filter_in );
err = put_filter( ber, filter );
LDAP_FREE( filter );
return( -1 );
*next = '\0';
- tmp = strdup( str );
+ tmp = LDAP_STRDUP( str );
if ( gotescape ) {
escape = 0;
for ( s = d = tmp; *s; s++ ) {
Debug( LDAP_DEBUG_TRACE, "put_filter: default\n", 0, 0,
0 );
next = strchr( str, '\0' );
- tmp = strdup( str );
+ tmp = LDAP_STRDUP( str );
if ( strchr( tmp, '\\' ) != NULL ) {
escape = 0;
for ( s = d = tmp; *s; s++ ) {
return( NULL );
}
- memcpy( p, s, len );
- return( p );
-}
-
-char *
-(ldap_int_strdup)( const char *s )
-{
- char *p;
- size_t len = strlen( s ) + 1;
-
- if ( (p = (char *) LDAP_MALLOC( len )) == NULL ) {
- return( NULL );
- }
-
memcpy( p, s, len );
return( p );
}
\ No newline at end of file
* 2 )) == NULL ) {
return( ld->ld_errno = LDAP_NO_MEMORY );
}
- dns[0] = strdup( prefix );
+ dns[0] = LDAP_STRDUP( prefix );
dns[1] = NULL;
} else {
dns = NULL;
if ( ld->ld_ufnprefix != NULL )
LDAP_FREE( ld->ld_ufnprefix );
- ld->ld_ufnprefix = strdup( prefix );
+ ld->ld_ufnprefix = LDAP_STRDUP( prefix );
}
int
}
/* make working copy of the remainder of the URL */
- if (( url = strdup( url_tmp )) == NULL ) {
+ if (( url = LDAP_STRDUP( url_tmp )) == NULL ) {
return( LDAP_URL_ERR_MEM );
}
if ( ludp->lud_host != NULL || ludp->lud_port != 0 ) {
if (( srv = (LDAPServer *)LDAP_CALLOC( 1, sizeof( LDAPServer )))
- == NULL || ( srv->lsrv_host = strdup( ludp->lud_host ==
+ == NULL || ( srv->lsrv_host = LDAP_STRDUP( ludp->lud_host ==
NULL ? ld->ld_defhost : ludp->lud_host )) == NULL ) {
if ( srv != NULL ) {
LDAP_FREE( srv );