FILE *rejfp;
struct LDIFFP *ldiffp, ldifdummy = {0};
char *matched_msg, *error_msg;
- int rc, retval;
+ int rc, retval, ldifrc;
int len;
int i = 0;
int lineno, nextline = 0, lmax = 0;
rc = 0;
retval = 0;
lineno = 1;
- while (( rc == 0 || contoper ) && ldif_read_record( ldiffp, &nextline,
- &rbuf, &lmax ))
+ while (( rc == 0 || contoper ) && ( ldifrc = ldif_read_record( ldiffp, &nextline,
+ &rbuf, &lmax )) > 0 )
{
if ( rejfp ) {
len = strlen( rbuf );
}
ber_memfree( rbuf );
+ if ( ldifrc < 0 )
+ retval = LDAP_OTHER;
+
#ifdef LDAP_X_TXN
if( retval == 0 && txn ) {
rc = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, NULL );
#define LDIF_MAXLINE 4096
/*
- * ldif_read_record - read an ldif record. Return 1 for success, 0 for EOF.
+ * ldif_read_record - read an ldif record. Return 1 for success, 0 for EOF,
+ * -1 for error.
*/
int
ldif_read_record(
*/
ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug,
_("ldif_read_record: include %s failed\n"), ptr );
- return 0;
+ return -1;
}
}
}
{
backsql_info *bi = (backsql_info *)be->be_private;
LDIFFP *fp;
- int rc = 0, lineno = 0, lmax = 0;
+ int rc = 0, lineno = 0, lmax = 0, ldifrc;
char *buf = NULL;
assert( fname != NULL );
bi->sql_baseObject->e_nname = be->be_nsuffix[0];
bi->sql_baseObject->e_attrs = NULL;
- while ( ldif_read_record( fp, &lineno, &buf, &lmax ) ) {
+ while (( ldifrc = ldif_read_record( fp, &lineno, &buf, &lmax )) > 0 ) {
Entry *e = str2entry( buf );
Attribute *a;
"dn=\"%s\" (line=%d)\n",
e->e_name.bv_val, lineno );
entry_free( e );
- rc = EXIT_FAILURE;
+ rc = LDAP_OTHER;
break;
}
}
}
+ if ( ldifrc < 0 )
+ rc = LDAP_OTHER;
+
if ( rc ) {
entry_free( bi->sql_baseObject );
bi->sql_baseObject = NULL;
root_dse_read_file( const char *fname )
{
struct LDIFFP *fp;
- int rc = 0, lineno = 0, lmax = 0;
+ int rc = 0, lineno = 0, lmax = 0, ldifrc;
char *buf = NULL;
if ( (fp = ldif_open( fname, "r" )) == NULL ) {
}
usr_attr->e_attrs = NULL;
- while( ldif_read_record( fp, &lineno, &buf, &lmax ) ) {
+ while(( ldifrc = ldif_read_record( fp, &lineno, &buf, &lmax )) > 0 ) {
Entry *e = str2entry( buf );
Attribute *a;
Debug( LDAP_DEBUG_ANY, "root_dse_read_file: "
"could not parse entry (file=\"%s\" line=%d)\n",
fname, lineno, 0 );
- rc = EXIT_FAILURE;
+ rc = LDAP_OTHER;
break;
}
"- dn=\"%s\" (file=\"%s\" line=%d)\n",
e->e_dn, fname, lineno );
entry_free( e );
- rc = EXIT_FAILURE;
+ rc = LDAP_OTHER;
break;
}
if (rc) break;
}
+ if ( ldifrc < 0 )
+ rc = LDAP_OTHER;
+
if (rc) {
entry_free( usr_attr );
usr_attr = NULL;
int match;
int checkvals;
- int lineno, nextline;
+ int lineno, nextline, ldifrc;
int lmax;
int rc = EXIT_SUCCESS;
int manage = 0;
}
/* nextline is the line number of the end of the current entry */
- for( lineno=1; ldif_read_record( ldiffp, &nextline, &buf, &lmax );
+ for( lineno=1; ( ldifrc = ldif_read_record( ldiffp, &nextline, &buf, &lmax )) > 0;
lineno=nextline+1 )
{
BackendDB *bd;
entry_free( e );
}
+ if ( ldifrc < 0 )
+ rc = EXIT_FAILURE;
+
bvtext.bv_len = textlen;
bvtext.bv_val = textbuf;
bvtext.bv_val[0] = '\0';