Never let ldif_parse_line() return a NULL value with success.

This commit is contained in:
Hallvard Furuseth 2002-12-02 22:46:07 +00:00
parent 3121074ad7
commit 416aeb9347
4 changed files with 17 additions and 26 deletions

View File

@ -976,12 +976,12 @@ process_ldif_rec( char *rbuf, int count )
{
if( val.bv_len == 0 || atoi(val.bv_val) != 1 ) {
fprintf( stderr, "%s: invalid version %s, line %d (ignored)\n",
prog, val.bv_val == NULL ? "(null)" : val.bv_val, linenum );
prog, val.bv_val, linenum );
}
version++;
} else if ( strcasecmp( type, T_DN_STR ) == 0 ) {
if (( dn = ber_strdup( val.bv_val ? val.bv_val : "" )) == NULL ) {
if (( dn = ber_strdup( val.bv_val )) == NULL ) {
perror( "strdup" );
exit( EXIT_FAILURE );
}
@ -1097,7 +1097,7 @@ process_ldif_rec( char *rbuf, int count )
if ( expect_newrdn ) {
if ( strcasecmp( type, T_NEWRDNSTR ) == 0 ) {
if (( newrdn = ber_strdup( val.bv_val ? val.bv_val : "" )) == NULL ) {
if (( newrdn = ber_strdup( val.bv_val )) == NULL ) {
perror( "strdup" );
exit( EXIT_FAILURE );
}
@ -1121,7 +1121,7 @@ process_ldif_rec( char *rbuf, int count )
}
} else if ( expect_newsup ) {
if ( strcasecmp( type, T_NEWSUPSTR ) == 0 ) {
if (( newsup = ber_strdup( val.bv_val ? val.bv_val : "" )) == NULL ) {
if (( newsup = ber_strdup( val.bv_val )) == NULL ) {
perror( "strdup" );
exit( EXIT_FAILURE );
}
@ -1137,7 +1137,7 @@ process_ldif_rec( char *rbuf, int count )
prog, linenum, dn );
rc = LDAP_PARAM_ERROR;
} else {
addmodifyop( &pmods, modop, type, val.bv_val == NULL ? NULL : &val );
addmodifyop( &pmods, modop, type, &val );
}
end_line:

View File

@ -143,9 +143,8 @@ ldif_parse_line(
/* no value is present, error out */
ber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug,
"ldif_parse_line: %s missing base64 value\n", type );
value = NULL;
vlen = 0;
goto done;
ber_memfree( freeme );
return( -1 );
}
byte = value = s;
@ -196,9 +195,8 @@ ldif_parse_line(
/* no value is present, error out */
ber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug,
"ldif_parse_line: %s missing URL value\n", type );
value = NULL;
vlen = 0;
goto done;
ber_memfree( freeme );
return( -1 );
}
if( ldif_fetch_url( s, &value, &vlen ) ) {
@ -214,7 +212,6 @@ ldif_parse_line(
vlen = (int) (d - s);
}
done:
type = ber_strdup( type );
if( type == NULL ) {
@ -225,7 +222,7 @@ done:
return( -1 );
}
if( !url && value != NULL ) {
if( !url ) {
p = ber_memalloc( vlen + 1 );
if( p == NULL ) {
ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug,

View File

@ -112,15 +112,13 @@ str2entry( char *s )
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1, "str2entry: "
"entry %ld has multiple DNs \"%s\" and \"%s\"\n",
(long) e->e_id, e->e_dn,
vals[0].bv_val != NULL ? vals[0].bv_val : "" );
(long) e->e_id, e->e_dn, vals[0].bv_val );
#else
Debug( LDAP_DEBUG_ANY, "str2entry: "
"entry %ld has multiple DNs \"%s\" and \"%s\"\n",
(long) e->e_id, e->e_dn,
vals[0].bv_val != NULL ? vals[0].bv_val : "" );
(long) e->e_id, e->e_dn, vals[0].bv_val );
#endif
if( vals[0].bv_val != NULL ) free( vals[0].bv_val );
free( vals[0].bv_val );
entry_free( e );
return NULL;
}

View File

@ -221,13 +221,11 @@ Re_parse(
type, 0, 0 );
#endif
free( type );
if ( value != NULL )
free( value );
return -1;
}
}
free( type );
if ( value != NULL )
free( value );
}
@ -367,7 +365,6 @@ get_repl_hosts(
free( type );
if ( !repl_ok ) {
warn_unknown_replica( value, port );
if ( value != NULL )
free( value );
continue;
}
@ -387,7 +384,6 @@ get_repl_hosts(
rh[ nreplicas ].rh_port = port;
nreplicas++;
if ( value != NULL )
free( value );
}