[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: Did you get the OpenLDAP ldbmcat crash problem fixed ? (ITS#106)



Folks,

I have once again had a look to the ldbmcat crash problem. As it turned
out (Sumit, have you tested already ?), the newly allocated key in the
loop was deleted before using it in ldbm_fetch :-( I have moved free'ing
up the memory of the last key to the end of the loop, so that new keys are
usable within the loop.


Regards,
Kurt Spanier


On Wed, 24 Mar 1999, Sumit A. Vakil wrote:

> Date: Wed, 24 Mar 1999 08:17:23 -0800
> From: "Sumit A. Vakil" <svakil@internetdevices.com>
> To: Kurt Spanier <kurt.spanier@zdv.uni-tuebingen.de>
> Cc: Yusuf Goolamabbas <yusufg@outblaze.com>, openldap-core@openldap.org
> Subject: RE: Did you get the OpenLDAP ldbmcat crash problem fixed ?
> 
> #include "portable.h"
> 
> #include <stdio.h>
> 
> #include <ac/ctype.h>
> #include <ac/socket.h>
> #include <ac/string.h>
> 
> #include "ldbm.h"
> #include "../slap.h"
> 
> static void
> usage( char *name )
> {
>         fprintf( stderr, "usage: %s [-n] <filename>\n", name );
>         exit( 1 );
> }
> 
> int
> main( int argc, char **argv )
> {
>         Datum                key, last, data;
>         LDBM                dbp;
>         int                rc, type;
>         long                id;
>         char                *file, *s;
>         int                printid = 1;
> 
> #ifdef HAVE_BERKELEY_DB2
>         DBC        *cursorp;
> #endif
> 
>         ldbm_datum_init( key );
>         ldbm_datum_init( last );
>         ldbm_datum_init( data );
> 
>         if ( argc < 2 || argc > 3 || ( argc == 3 && strcmp( argv[1], "-n" )
>             != 0 )) {
>                 usage( argv[0] );
>         }
>         if ( argc == 3 && strcmp( argv[1], "-n" ) == 0 ) {
>                 printid = 0;
>                 file = argv[2];
>         } else {
>                 file = argv[1];
>         }
> 
>         if ( (dbp = ldbm_open( file, LDBM_READER, 0, 0 )) == NULL ) {
>                 perror( file );
>                 exit ( 1 );
>         }
> 
>         last.dptr = NULL;
> 
> #ifdef HAVE_BERKELEY_DB2
>         for ( key = ldbm_firstkey( dbp, &cursorp ); key.dptr != NULL;
>             key = ldbm_nextkey( dbp, last, cursorp ) )
> #else
>         for ( key = ldbm_firstkey( dbp ); key.dptr != NULL;
>             key = ldbm_nextkey( dbp, last ) )
> #endif
>         {
> 
> /* Begin Internet Devices mods. */
> #ifdef HAVE_BERKELEY_DB2
> 		key.flags = 0;
>                 data = ldbm_fetch( dbp, key );
> 		key.flags = DB_DBT_MALLOC;
> #else
>                 if ( last.dptr != NULL )
>                         ldbm_datum_free( dbp, last );
>                 data = ldbm_fetch( dbp, key );
> #endif HAVE_BERKELEY_DB2
> /* End Internet Devices mods. */
> 
>                 if (( s = data.dptr ) != NULL ) {
> 
>                     if ( !printid && isdigit( *s )) {
>                         if (( s = strchr( s, '\n' )) != NULL ) {
>                                 ++s;
>                         }
>                     }
>                     if ( s != NULL ) {
>                         puts( s );
>                     }
> 
>                     if ( data.dptr != NULL ) {
>                         ldbm_datum_free( dbp, data );
>                     }
> 
>                 }
> 
>                 last = key;
>         }
> 
> /* Begin Internet Devices mods. */
> #ifndef HAVE_BERKELEY_DB2
>         if ( last.dptr != NULL )
>                 ldbm_datum_free( dbp, last );
> #endif HAVE_BERKELEY_DB2
> /* End Internet Devices mods. */
> 
>         ldbm_close( dbp );
> 
>         exit( 0 );
> }
> 
> > -----Original Message-----
> > From: Kurt Spanier [mailto:kurt.spanier@zdv.uni-tuebingen.de]
> > Sent: Wednesday, March 24, 1999 8:07 AM
> > To: Sumit A. Vakil
> > Cc: Yusuf Goolamabbas; openldap-core@openldap.org
> > Subject: RE: Did you get the OpenLDAP ldbmcat crash problem fixed ?
> >
> >
> > Hello,
> >
> > I'm quite sure, I have commited the changes two weeks ago, so it should be
> > part of the latest -devel.
> >
> > Nonetheless, I cannot read your attached patch file. Could you please send
> > it again in plain ascii. Otherwise, I could not say anything.
> >
> >
> > Kurt
> >
> >
> > On Wed, 24 Mar 1999, Sumit A. Vakil wrote:
> >
> > > Date: Wed, 24 Mar 1999 07:27:31 -0800
> > > From: "Sumit A. Vakil" <svakil@internetdevices.com>
> > > To: Yusuf Goolamabbas <yusufg@outblaze.com>
> > > Cc: zrnsk01@zdv.uni-tuebingen.de
> > > Subject: RE: Did you get the OpenLDAP ldbmcat crash problem fixed ?
> > >
> > > I got e-mail from Kurt a while back which said that he had fixed the
> > > problem.  Don't know if he's put the fix in yet.
> > >
> > > Yes, I fixed the problem.  We don't have trouble with ldbmcat
> > anymore.  I've
> > > attached the fixed ldbmcat.c file to this e-mail.  The changes
> > I've made are
> > > between comments of the form
> > > /* Begin Internet Devices mods. */ and /* End Internet Devices mods. */.
> > > I'm not an expert on the OpenLDAP code so it might not be the
> > best way to
> > > fix the problem.  But the changes are working for us and we
> > make frequent
> > > use of ldbmcat.
> > >
> > > Regards,
> > >
> > > Sumit
> > >
> > > > -----Original Message-----
> > > > From: Yusuf Goolamabbas [mailto:yusufg@outblaze.com]
> > > > Sent: Tuesday, March 23, 1999 9:56 PM
> > > > To: svakil@internetdevices.com
> > > > Cc: zrnsk01@zdv.uni-tuebingen.de
> > > > Subject: Did you get the OpenLDAP ldbmcat crash problem fixed ?
> > > >
> > > >
> > > > Hi Sumit, I have configured both OpenLDAP 1.2 as well OpenLDAP CVS
> > > > (checked out a few hours ago) on a FreeBSD 3.1-STABLE box with
> > > > Berkeley DB 2.3.16.
> > > >
> > > > In both cases, whilst running ldbmcat. I get a core dump or sometimes
> > > > ldbmcat returns nothing.
> > > >
> > > > According to cvsweb, Kurt Spanier (messg cc'ed to him) had apparently
> > > > fixed the ITS.
> > > >
> > > > Are you still facing the same problem or you have a workaround/fix ?
> > > >
> > > > Thanks, Yusuf
> > > >
> > >
> >
> >
> > ----------==========#########>>>>>ZDV<<<<<#########==========----------
> >
> > X.500:                                              Tel.:
> >    Kurt Spanier, Zentrum fuer Datenverarbeitung,      +49 7071 29-70334
> >    Universitaet Tuebingen, DE
> > SMTP-Mail:                                          FAX.:
> >    kurt.spanier@zdv.uni-tuebingen.de                   +49 7071 29-5912
> > Snail-Mail:
> >    Dr. Kurt Spanier, Zentrum fuer Datenverarbeitung,
> >    Universitaet Tuebingen, Waechterstrasse 76, D-72074 Tuebingen
> > PGP-Public-Key:
> >    finger "Kurt Spanier"@x500.uni-tuebingen.de
> >
> > ----------==========##########>>>>>@<<<<<##########==========----------
> >
> >
> >
> 


----------==========#########>>>>>ZDV<<<<<#########==========----------

X.500:                                              Tel.:
   Kurt Spanier, Zentrum fuer Datenverarbeitung,      +49 7071 29-70334
   Universitaet Tuebingen, DE
SMTP-Mail:                                          FAX.:
   kurt.spanier@zdv.uni-tuebingen.de                   +49 7071 29-5912
Snail-Mail:
   Dr. Kurt Spanier, Zentrum fuer Datenverarbeitung,
   Universitaet Tuebingen, Waechterstrasse 76, D-72074 Tuebingen
PGP-Public-Key:
   finger "Kurt Spanier"@x500.uni-tuebingen.de

----------==========##########>>>>>@<<<<<##########==========----------