+/* $OpenLDAP$ */
/*
* Copyright (c) 1996 Regents of the University of Michigan.
* All rights reserved.
#include <stdio.h>
+#include <ac/stdlib.h>
#include <ac/string.h>
#include <ac/socket.h>
+#include <ac/ctype.h>
#include <lber.h>
#include <ldap.h>
)
{
FILE *fp;
- char buf[BUFSIZ];
- char *line, *p;
+ char *line;
int cargc;
char *cargv[MAXARGS];
if ( (fp = fopen( fname, "r" )) == NULL ) {
perror( fname );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
lineno = 0;
"line %d: missing filename in \"replogfile ",
lineno );
fprintf( stderr, "<filename>\" line\n" );
- exit( 1 );
+ exit( EXIT_FAILURE );
} else if ( cargc > 2 && *cargv[2] != '#' ) {
fprintf( stderr,
"line %d: extra cruft at the end of \"replogfile %s\"",
lineno, cargv[1] );
fprintf( stderr, "line (ignored)\n" );
}
- sprintf( sglob->slapd_replogfile, cargv[1] );
+ strcpy( sglob->slapd_replogfile, cargv[1] );
}
} else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
add_replica( cargv, cargc );
} else {
inquote = 1;
}
- strcpy( next, next + 1 );
+ SAFEMEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
break;
case '\\':
- strcpy( next, next + 1 );
+ if ( next[1] )
+ SAFEMEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
+ next++; /* dont parse the escaped character */
break;
default:
*p = '\0';
}
lineno++;
- if ( ! isspace( buf[0] ) ) {
+ if ( ! isspace( (unsigned char) buf[0] ) ) {
return( line );
}
( nr + 1 ) * sizeof( Re * ));
if ( sglob->replicas == NULL ) {
fprintf( stderr, "out of memory, add_replica\n" );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
sglob->replicas[ nr ] = NULL;
if ( Ri_init( &(sglob->replicas[ nr - 1 ])) < 0 ) {
fprintf( stderr, "out of memory, Ri_init\n" );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
if ( parse_replica_line( cargv, cargc,
sglob->replicas[ nr - 1] ) < 0 ) {
sglob->replicas[ nr - 1 ] );
if ( sglob->replicas[ nr - 1]->ri_stel == NULL ) {
fprintf( stderr, "Failed to add status element structure\n" );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
}
}
ri->ri_port = atoi( hp );
}
if ( ri->ri_port <= 0 ) {
- ri->ri_port = LDAP_PORT;
+ ri->ri_port = 0;
}
ri->ri_hostname = strdup( val );
gots |= GOT_HOST;
strlen( BINDMETHSTR ))) {
val = cargv[ i ] + strlen( BINDMETHSTR ) + 1;
if ( !strcasecmp( val, KERBEROSSTR )) {
-#ifdef HAVE_KERBEROS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
ri->ri_bind_method = AUTH_KERBEROS;
if ( ri->ri_srvtab == NULL ) {
ri->ri_srvtab = strdup( sglob->default_srvtab );
}
gots |= GOT_METHOD;
-#else /* HAVE_KERBEROS */
+#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
fprintf( stderr, "Error: a bind method of \"kerberos\" was\n" );
fprintf( stderr, "specified in the slapd configuration file,\n" );
fprintf( stderr, "but slurpd was not built with kerberos.\n" );
fprintf( stderr, "You must rebuild the LDAP release with\n" );
fprintf( stderr, "kerberos support if you wish to use\n" );
fprintf( stderr, "bindmethod=kerberos\n" );
- exit( 1 );
-#endif /* HAVE_KERBEROS */
+ exit( EXIT_FAILURE );
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
} else if ( !strcasecmp( val, SIMPLESTR )) {
ri->ri_bind_method = AUTH_SIMPLE;
gots |= GOT_METHOD;