From: Kurt Spanier Date: Fri, 18 Dec 1998 12:28:47 +0000 (+0000) Subject: Initialization of Datum structures to zero by memset() before first use. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~922 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9e97da14fbda2b4516c0e732673dee28b5b9af13;p=openldap Initialization of Datum structures to zero by memset() before first use. If Berkeley DB version 2.x is used as a slapd back-end a not-initialized Datum structure will raise an EINVAL error in (DB)->put(). --- diff --git a/servers/slapd/tools/centipede.c b/servers/slapd/tools/centipede.c index 5cc275f8b1..11e46ba469 100644 --- a/servers/slapd/tools/centipede.c +++ b/servers/slapd/tools/centipede.c @@ -473,6 +473,8 @@ generate_new_centroids( char **val; char last; + memset( &data, 0 , sizeof( data )); + if ( verbose ) { printf( "Generating new centroids for..." ); fflush( stdout ); @@ -495,6 +497,9 @@ generate_new_centroids( /* for each value */ for ( j = 0; val[j] != NULL; j++ ) { + + memset( &key, 0 , sizeof( key )); + /* normalize the value */ for ( s = val[j]; *s; s++ ) { if ( isascii( *s ) ) { @@ -570,6 +575,14 @@ diff_centroids( fflush( stdout ); } + memset( &okey, 0, sizeof( okey )); + memset( &nkey, 0, sizeof( nkey )); + memset( &olast, 0, sizeof( olast )); + memset( &nlast, 0, sizeof( nlast )); + memset( &lastkey, 0, sizeof( lastkey )); + memset( &key, 0, sizeof( key )); + memset( &data, 0, sizeof( data )); + if ( (mods = (LDAPMod **) malloc( sizeof(LDAPMod *) * 4 )) == NULL || (mods[0] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL || (mods[1] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL || @@ -832,6 +845,9 @@ full_centroid( fflush( stdout ); } + memset( &key, 0, sizeof( key )); + memset( &lastkey, 0, sizeof( lastkey )); + if ( (mods = (LDAPMod **) malloc( sizeof(LDAPMod *) * 3 )) == NULL || (mods[0] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL || (mods[1] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL || diff --git a/servers/slapd/tools/ldbmcat.c b/servers/slapd/tools/ldbmcat.c index ad05811447..40208ab86e 100644 --- a/servers/slapd/tools/ldbmcat.c +++ b/servers/slapd/tools/ldbmcat.c @@ -28,6 +28,10 @@ main( int argc, char **argv ) #ifdef HAVE_BERKELEY_DB2 DBC *cursorp; + + memset( &key, 0, sizeof( key )); + memset( &last, 0, sizeof( last )); + memset( &data, 0, sizeof( data )); #endif if ( argc < 2 || argc > 3 || ( argc == 3 && strcmp( argv[1], "-n" ) diff --git a/servers/slapd/tools/ldbmtest.c b/servers/slapd/tools/ldbmtest.c index 99fdee67c8..29faae9987 100644 --- a/servers/slapd/tools/ldbmtest.c +++ b/servers/slapd/tools/ldbmtest.c @@ -68,6 +68,11 @@ main( int argc, char **argv ) #ifdef HAVE_BERKELEY_DB2 DBC *cursorp; + + memset( &savekey, 0, sizeof( savekey )); + memset( &key, 0, sizeof( key )); + memset( &data, 0, sizeof( data )); + memset( &last, 0, sizeof( last )); #endif tailorfile = SLAPD_DEFAULT_CONFIGFILE; diff --git a/servers/slapd/tools/ldif2id2children.c b/servers/slapd/tools/ldif2id2children.c index 30dffcf688..cbe925f666 100644 --- a/servers/slapd/tools/ldif2id2children.c +++ b/servers/slapd/tools/ldif2id2children.c @@ -149,6 +149,9 @@ main( int argc, char **argv ) int vlen; Datum key, data; + memset( &key, 0, sizeof( key )); + memset( &data, 0, sizeof( data )); + if ( fgets( line, sizeof(line), stdin ) != NULL ) { int len; @@ -232,6 +235,9 @@ main( int argc, char **argv ) char buf2[20]; Datum key, data; + memset( &key, 0, sizeof( key )); + memset( &data, 0, sizeof( data )); + if ( fgets( line, sizeof(line), stdin ) != NULL ) { int len; diff --git a/servers/slapd/tools/ldif2id2entry.c b/servers/slapd/tools/ldif2id2entry.c index 903c8b8d42..4ff3407d55 100644 --- a/servers/slapd/tools/ldif2id2entry.c +++ b/servers/slapd/tools/ldif2id2entry.c @@ -141,6 +141,9 @@ main( int argc, char **argv ) int vlen; Datum key, data; + memset( &key, 0, sizeof( key )); + memset( &data, 0, sizeof( data )); + if ( fgets( line, sizeof(line), stdin ) != NULL ) { int len, idlen; diff --git a/servers/slapd/tools/ldif2ldbm.c b/servers/slapd/tools/ldif2ldbm.c index 53c8fa008c..8ab191d7e0 100644 --- a/servers/slapd/tools/ldif2ldbm.c +++ b/servers/slapd/tools/ldif2ldbm.c @@ -224,6 +224,9 @@ main( int argc, char **argv ) int vlen, indexmask, syntaxmask; Datum key, data; + memset( &key, 0, sizeof( key )); + memset( &data, 0, sizeof( data )); + if ( fgets( line, sizeof(line), stdin ) != NULL ) { int len; diff --git a/servers/slapd/tools/sizecount.c b/servers/slapd/tools/sizecount.c index c88ff565c5..74cb7a6b4f 100644 --- a/servers/slapd/tools/sizecount.c +++ b/servers/slapd/tools/sizecount.c @@ -94,6 +94,9 @@ main( int argc, char **argv ) Datum key, data; char *w; + memset( &key, 0, sizeof( key )); + memset( &data, 0, sizeof( data )); + /* update value count */ vcount++; vsize += bvals[j]->bv_len; @@ -176,6 +179,9 @@ add( { Datum key, data; + memset( &key, 0, sizeof( key )); + memset( &data, 0, sizeof( data )); + key.dptr = s; key.dsize = strlen( key.dptr ) + 1; data.dptr = "";