From: Kurt Spanier Date: Mon, 29 Mar 1999 16:01:59 +0000 (+0000) Subject: Fix ldbmcat crash problem: first use the key before deleting it! X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~309 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=80400aba5252d7b2db0b74df0bd259ba1e25bbb2;p=openldap Fix ldbmcat crash problem: first use the key before deleting it! --- diff --git a/libraries/libldbm/ldbm.c b/libraries/libldbm/ldbm.c index 4c93207929..ba29697839 100644 --- a/libraries/libldbm/ldbm.c +++ b/libraries/libldbm/ldbm.c @@ -25,8 +25,7 @@ ldbm_datum_free( LDBM ldbm, Datum data ) { if ( data.dptr ) { free( data.dptr ); - data.dptr = NULL; - data.dsize = 0; + memset( &data, 0, sizeof( Datum )); } } @@ -327,7 +326,6 @@ ldbm_firstkey( LDBM ldbm ) if ( (*ldbm->cursor)( ldbm, NULL, &dbci, 0 )) # endif { - key.flags = 0; key.dptr = NULL; return( key ); } else { @@ -336,7 +334,6 @@ ldbm_firstkey( LDBM ldbm ) ldbm_datum_free( ldbm, data ); } else { - key.flags = 0; #else int rc; @@ -381,7 +378,6 @@ ldbm_nextkey( LDBM ldbm, Datum key ) ldbm_datum_free( ldbm, data ); } else { - key.flags = 0; #else int rc; diff --git a/servers/slapd/tools/ldbmcat.c b/servers/slapd/tools/ldbmcat.c index 5cb82466e1..0538001735 100644 --- a/servers/slapd/tools/ldbmcat.c +++ b/servers/slapd/tools/ldbmcat.c @@ -26,8 +26,6 @@ main( int argc, char **argv ) #ifdef HAVE_BERKELEY_DB2 DBC *cursorp; - - if ( ldbm_initialize() ) exit( 1 ); #endif ldbm_datum_init( key ); @@ -60,8 +58,6 @@ main( int argc, char **argv ) key = ldbm_nextkey( dbp, last ) ) #endif { - ldbm_datum_free( dbp, last ); - data = ldbm_fetch( dbp, key ); if (( s = data.dptr ) != NULL ) { @@ -77,18 +73,17 @@ main( int argc, char **argv ) ldbm_datum_free( dbp, data ); - } + } else { + + } + ldbm_datum_free( dbp, last ); last = key; } ldbm_datum_free( dbp, last ); ldbm_close( dbp ); -#ifdef HAVE_BERKELEY_DB2 - (void) ldbm_shutdown(); -#endif - exit( 0 ); return 0; /* NOT REACHED */ diff --git a/tests/scripts/test001-ldif2ldbm b/tests/scripts/test001-ldif2ldbm index 547aa830d3..6ab1a5c52b 100755 --- a/tests/scripts/test001-ldif2ldbm +++ b/tests/scripts/test001-ldif2ldbm @@ -28,7 +28,7 @@ if [ $RC != 0 ]; then fi echo "Starting slapd on TCP/IP port $PORT..." -$SLAPD -f $CONF -p $PORT -a $ADDR -d $LVL $TIMING > $MASTERLOG 2>&1 & +$SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 & PID=$! echo "Using ldapsearch to retrieve all the entries..." diff --git a/tests/scripts/test001-slapadd b/tests/scripts/test001-slapadd index 547aa830d3..6ab1a5c52b 100755 --- a/tests/scripts/test001-slapadd +++ b/tests/scripts/test001-slapadd @@ -28,7 +28,7 @@ if [ $RC != 0 ]; then fi echo "Starting slapd on TCP/IP port $PORT..." -$SLAPD -f $CONF -p $PORT -a $ADDR -d $LVL $TIMING > $MASTERLOG 2>&1 & +$SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 & PID=$! echo "Using ldapsearch to retrieve all the entries..."