+/* $OpenLDAP$ */
/*
* Copyright (c) 1996 Regents of the University of Michigan.
* All rights reserved.
int state;
int nml;
char *buf, *rp, *p;
- long buflen;
+ size_t buflen;
char *type, *value;
- int len;
+ ber_len_t len;
int nreplicas;
if ( re == NULL ) {
if ( strncmp( buf, ERROR_STR, strlen( ERROR_STR )) == 0 ) {
continue;
}
- buflen = ( long ) strlen( buf );
+ buflen = strlen( buf );
if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) {
Debug( LDAP_DEBUG_ANY,
"Error: Re_parse: malformed replog file\n",
Debug( LDAP_DEBUG_ANY,
"Error: Re_parse: bad type <%s>\n",
type, 0, 0 );
+ free( type );
+ if ( value != NULL )
+ free( value );
return -1;
}
}
+ free( type );
+ if ( value != NULL )
+ free( value );
}
if ( state != GOT_ALL ) {
}
for (;;) {
+ char *const dash = "-";
+
if (( buf = ldif_getline( &rp )) == NULL ) {
break;
}
- buflen = ( long ) strlen( buf );
+ buflen = strlen( buf );
if (( buflen == 1 ) && ( buf[ 0 ] == '-' )) {
- type = "-";
+ type = dash;
value = NULL;
} else {
if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) {
re->re_mods[ nml + 1 ].mi_type = NULL;
re->re_mods[ nml + 1 ].mi_val = NULL;
nml++;
+
+ if ( type != dash )
+ free( type );
+ if ( value != NULL )
+ free( value );
}
return 0;
}
char **r_rp
)
{
- char buf[ LDIF_LINE_WIDTH + 1 ];
char *type, *value, *line, *p;
Rh *rh = NULL;
- int nreplicas, len;
+ int nreplicas;
+ ber_len_t len;
int port;
int repl_ok;
int i;
break;
}
}
+ free( type );
if ( !repl_ok ) {
warn_unknown_replica( value, port );
+ if ( value != NULL )
+ free( value );
continue;
}
rh[ nreplicas ].rh_hostname = strdup( value );
rh[ nreplicas ].rh_port = port;
nreplicas++;
+
+ if ( value != NULL )
+ free( value );
}
if ( nreplicas == 0 ) {
}
} else {
char *obuf;
- obuf = ldif_type_and_value( re->re_mods[ i ].mi_type,
+ obuf = ldif_put( LDIF_PUT_VALUE,
+ re->re_mods[ i ].mi_type,
re->re_mods[ i ].mi_val ? re->re_mods[ i ].mi_val : "",
re->re_mods[ i ].mi_len );
if ( fputs( obuf, fp ) < 0 ) {
free( obuf );
goto bad;
} else {
- free( obuf );
+ ber_memfree( obuf );
}
}
}