Entry *
str2entry( char *s )
{
- int i;
+ int id = 0;
Entry *e;
Attribute **a;
char *type;
Debug( LDAP_DEBUG_TRACE, "=> str2entry\n",
s ? s : "NULL", 0, 0 );
- e = (Entry *) ch_calloc( 1, sizeof(Entry) );
-
/* check to see if there's an id included */
next = s;
if ( isdigit( *s ) ) {
- e->e_id = atoi( s );
+ id = atoi( s );
if ( (s = ldif_getline( &next )) == NULL ) {
Debug( LDAP_DEBUG_TRACE,
"<= str2entry NULL (missing newline after id)\n",
0, 0, 0 );
- free( e );
return( NULL );
}
}
/* initialize reader/writer lock */
+ e = (Entry *) ch_calloc( 1, sizeof(Entry) );
+
+ if( e == NULL ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<= str2entry NULL (entry allocation failed)\n",
+ 0, 0, 0 );
+ return( NULL );
+ }
+ e->e_id = id;
+
entry_rdwr_init(e);
/* dn + attributes */
maxvals = 0;
a = NULL;
}
+
if ( strcasecmp( type, "dn" ) == 0 ) {
if ( e->e_dn != NULL ) {
Debug( LDAP_DEBUG_ANY,
continue;
}
e->e_dn = ch_strdup( value );
+
+ if ( e->e_ndn != NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "str2entry: entry %lu already has a normalized dn \"%s\" for \"%s\" (first ignored)\n",
+ e->e_id, e->e_ndn, value );
+ free( e->e_ndn );
+ }
+ e->e_ndn = dn_normalize_case( ch_strdup( value ) );
continue;
}
return( NULL );
}
+ if ( e->e_ndn == NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "str2entry: entry %lu (\"%s\") has no normalized dn\n",
+ e->e_id, e->e_dn, 0 );
+ entry_free( e );
+ return( NULL );
+ }
+
Debug(LDAP_DEBUG_TRACE, "<= str2entry 0x%lx\n", (unsigned long)e, 0,0);
return( e );
if ( e->e_dn != NULL ) {
free( e->e_dn );
}
+ if ( e->e_ndn != NULL ) {
+ free( e->e_ndn );
+ }
for ( a = e->e_attrs; a != NULL; a = next ) {
next = a->a_next;
attr_free( a );