diff --git a/mozilla/directory/c-sdk/ldap/clients/tools/ldapdelete.c b/mozilla/directory/c-sdk/ldap/clients/tools/ldapdelete.c index 129cab1b786..f648857a3cd 100644 --- a/mozilla/directory/c-sdk/ldap/clients/tools/ldapdelete.c +++ b/mozilla/directory/c-sdk/ldap/clients/tools/ldapdelete.c @@ -47,7 +47,8 @@ int main( int argc, char **argv ) { char buf[ 4096 ]; - int rc, deref, optind; + int rc = 0; + int deref, optind; LDAPControl *ldctrl; #ifdef notdef @@ -95,7 +96,6 @@ main( int argc, char **argv ) free( conv ); } } else { - rc = 0; while ((rc == 0 || contoper) && fgets(buf, sizeof(buf), ldaptool_fp) != NULL) { buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */ diff --git a/mozilla/directory/c-sdk/ldap/clients/tools/ldapmodify.c b/mozilla/directory/c-sdk/ldap/clients/tools/ldapmodify.c index ff2dea4518f..064a21e4633 100644 --- a/mozilla/directory/c-sdk/ldap/clients/tools/ldapmodify.c +++ b/mozilla/directory/c-sdk/ldap/clients/tools/ldapmodify.c @@ -617,7 +617,7 @@ static int process_ldapmod_rec( char *rbuf ) { char *line, *dn, *p, *q, *attr, *value; - int rc, linenum, modop; + int rc, linenum; LDAPMod **pmods; pmods = NULL; @@ -681,7 +681,8 @@ process_ldapmod_rec( char *rbuf ) ldaptool_progname, linenum, attr ); rc = LDAP_PARAM_ERROR; } else { - switch ( *attr ) { + int modop = -1; /* an invalid value */ + switch ( *attr ) { case '-': modop = LDAP_MOD_DELETE; ++attr; @@ -697,8 +698,10 @@ process_ldapmod_rec( char *rbuf ) rc = LDAP_PARAM_ERROR; } - addmodifyop( &pmods, modop, attr, value, - ( value == NULL ) ? 0 : strlen( value )); + if ( rc == 0 && modop != -1 ) { + addmodifyop( &pmods, modop, attr, value, + ( value == NULL ) ? 0 : strlen( value )); + } } } diff --git a/mozilla/directory/c-sdk/ldap/clients/tools/ldapsearch.c b/mozilla/directory/c-sdk/ldap/clients/tools/ldapsearch.c index 551bf4b3c64..f6bfe95fa57 100644 --- a/mozilla/directory/c-sdk/ldap/clients/tools/ldapsearch.c +++ b/mozilla/directory/c-sdk/ldap/clients/tools/ldapsearch.c @@ -295,7 +295,8 @@ main( int argc, char **argv ) static void options_callback( int option, char *optarg ) { - char *s, *temp_arg, *ps_ptr, *ps_arg; + char *s, *ps_ptr, *ps_arg; + char *temp_arg = NULL; switch( option ) { case 'u': /* include UFN */ diff --git a/mozilla/directory/c-sdk/ldap/libraries/liblber/io.c b/mozilla/directory/c-sdk/ldap/libraries/liblber/io.c index 8d74e5be1b5..bfa132491cd 100644 --- a/mozilla/directory/c-sdk/ldap/libraries/liblber/io.c +++ b/mozilla/directory/c-sdk/ldap/libraries/liblber/io.c @@ -574,6 +574,7 @@ get_tag( Sockbuf *sb, BerElement *ber) return( LBER_DEFAULT ); } + /* we only handle small (one byte) tags */ if ( (xbyte & LBER_BIG_TAG_MASK) == LBER_BIG_TAG_MASK ) { return( LBER_DEFAULT ); } @@ -653,7 +654,7 @@ unsigned long LDAP_CALL ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) { - unsigned long tag, toread, newlen; + unsigned long toread; long rc; #ifdef LDAP_DEBUG @@ -668,7 +669,10 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) if ( ber->ber_rwptr == NULL ) { /* read the tag */ - if ((tag = get_tag(sb, ber)) == LBER_DEFAULT ) { + unsigned long tag = get_tag(sb, ber); + unsigned long newlen; + + if (tag == LBER_DEFAULT ) { return( LBER_DEFAULT ); } @@ -677,8 +681,6 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) return( LBER_DEFAULT); } - ber->ber_tag_contents[0] = (char)tag; /* we only handle 1 byte tags */ - /* read the length */ if ((newlen = read_len_in_ber(sb, ber)) == LBER_DEFAULT ) { return( LBER_DEFAULT ); @@ -740,9 +742,8 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) #endif ber->ber_rwptr = NULL; - *len = newlen; - ber->ber_struct[BER_STRUCT_VAL].ldapiov_len = newlen; - return(tag); + *len = ber->ber_struct[BER_STRUCT_VAL].ldapiov_len = ber->ber_len; + return(ber->ber_tag_contents[0]); } Sockbuf * diff --git a/mozilla/directory/c-sdk/ldap/libraries/libldap/cache.c b/mozilla/directory/c-sdk/ldap/libraries/libldap/cache.c index 8d4b8de4bdd..c7483580c03 100644 --- a/mozilla/directory/c-sdk/ldap/libraries/libldap/cache.c +++ b/mozilla/directory/c-sdk/ldap/libraries/libldap/cache.c @@ -115,7 +115,7 @@ nsldapi_add_result_to_cache( LDAP *ld, LDAPMessage *m ) mods[i] = (LDAPMod *)NSLDAPI_CALLOC( 1, sizeof(LDAPMod) ); mods[i]->mod_op = LDAP_MOD_BVALUES; mods[i]->mod_type = "cachedtime"; - sprintf( buf, "%d", time( NULL ) ); + sprintf( buf, "%ld", time( NULL ) ); bv.bv_val = buf; bv.bv_len = strlen( buf ); bvp[0] = &bv; diff --git a/mozilla/directory/c-sdk/ldap/libraries/libldap/error.c b/mozilla/directory/c-sdk/ldap/libraries/libldap/error.c index aa497beaf2d..c0991c4dd56 100644 --- a/mozilla/directory/c-sdk/ldap/libraries/libldap/error.c +++ b/mozilla/directory/c-sdk/ldap/libraries/libldap/error.c @@ -342,8 +342,8 @@ nsldapi_parse_result( LDAP *ld, int msgtype, BerElement *rber, int *errcodep, { BerElement ber; unsigned long len; - int berrc, err, errcode; - long along; + int berrc, err, errcode = 0; + long along = 0; char *m, *e; /* diff --git a/mozilla/directory/c-sdk/ldap/libraries/libldap/os-ip.c b/mozilla/directory/c-sdk/ldap/libraries/libldap/os-ip.c index 02f82ce9517..7073f02068c 100644 --- a/mozilla/directory/c-sdk/ldap/libraries/libldap/os-ip.c +++ b/mozilla/directory/c-sdk/ldap/libraries/libldap/os-ip.c @@ -539,11 +539,13 @@ nsldapi_try_each_host( LDAP *ld, const char *hostlist, #ifdef NSLDAPI_AVOID_OS_SOCKETS return -1; #else /* NSLDAPI_AVOID_OS_SOCKETS */ - int rc, i, s, err, connected, use_hp; + int rc = -1; + int s = 0; + int i, err, connected, use_hp; int parse_err, port; struct sockaddr_in sin; nsldapi_in_addr_t address; - char **addrlist, *ldhpbuf, *ldhpbuf_allocd; + char **addrlist, *ldhpbuf, *ldhpbuf_allocd = NULL; char *host; LDAPHostEnt ldhent, *ldhp; struct hostent *hp; diff --git a/mozilla/directory/c-sdk/ldap/libraries/libldap/request.c b/mozilla/directory/c-sdk/ldap/libraries/libldap/request.c index a9ecc572cf5..c3ad5235d75 100644 --- a/mozilla/directory/c-sdk/ldap/libraries/libldap/request.c +++ b/mozilla/directory/c-sdk/ldap/libraries/libldap/request.c @@ -353,8 +353,7 @@ LDAPConn * nsldapi_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, int connect, int bind ) { - int rc; - + int rc = -1; LDAPConn *lc; LDAPServer *prevsrv, *srv; Sockbuf *sb = NULL; @@ -886,7 +885,8 @@ int nsldapi_chase_v3_refs( LDAP *ld, LDAPRequest *lr, char **v3refs, int is_reference, int *totalcountp, int *chasingcountp ) { - int i, rc, unknown; + int rc = LDAP_SUCCESS; + int i, unknown; LDAPRequest *origreq; *totalcountp = *chasingcountp = 0; diff --git a/mozilla/directory/c-sdk/ldap/libraries/libldap/result.c b/mozilla/directory/c-sdk/ldap/libraries/libldap/result.c index 4a5aa090832..aa22c392fea 100644 --- a/mozilla/directory/c-sdk/ldap/libraries/libldap/result.c +++ b/mozilla/directory/c-sdk/ldap/libraries/libldap/result.c @@ -267,7 +267,7 @@ wait4msg( LDAP *ld, int msgid, int all, int unlock_permitted, struct timeval tv, *tvp; long start_time = 0, tmp_time; LDAPConn *lc, *nextlc; - LDAPRequest *lr; + LDAPRequest *lr = NULL; #ifdef LDAP_DEBUG if ( timeout == NULL ) { diff --git a/mozilla/directory/c-sdk/ldap/libraries/libldap/search.c b/mozilla/directory/c-sdk/ldap/libraries/libldap/search.c index 018049ebc63..7dd6f567a3f 100644 --- a/mozilla/directory/c-sdk/ldap/libraries/libldap/search.c +++ b/mozilla/directory/c-sdk/ldap/libraries/libldap/search.c @@ -789,7 +789,7 @@ unescape_filterval( char *val ) int escape, firstdigit, ival; char *s, *d; - escape = 0; + escape = firstdigit = 0; for ( s = d = val; *s; s++ ) { if ( escape ) { /* diff --git a/mozilla/directory/c-sdk/ldap/libraries/libldap/utf8.c b/mozilla/directory/c-sdk/ldap/libraries/libldap/utf8.c index 2515debe7c1..fa6431dffa8 100644 --- a/mozilla/directory/c-sdk/ldap/libraries/libldap/utf8.c +++ b/mozilla/directory/c-sdk/ldap/libraries/libldap/utf8.c @@ -109,7 +109,7 @@ ldap_utf8characters (const char* src) unsigned long LDAP_CALL ldap_utf8getcc( const char** src ) { - register unsigned long c; + register unsigned long c = 0; register const unsigned char* s = (const unsigned char*)*src; switch (UTF8len [(*s >> 2) & 0x3F]) { case 0: /* erroneous: s points to the middle of a character. */ diff --git a/mozilla/directory/c-sdk/ldap/libraries/libssldap/clientinit.c b/mozilla/directory/c-sdk/ldap/libraries/libssldap/clientinit.c index 8c49d26ca32..843c64c07dc 100644 --- a/mozilla/directory/c-sdk/ldap/libraries/libssldap/clientinit.c +++ b/mozilla/directory/c-sdk/ldap/libraries/libssldap/clientinit.c @@ -81,7 +81,7 @@ static char ptokDes[34] = "Internal (Software) Token "; static int splitpath(char *string, char *dir, char *prefix, char *key) { char *k; - char *s; + char *s = NULL; char *d = string; char *l; int len = 0; @@ -234,6 +234,7 @@ ldapssl_basic_init( const char *certdbpath, const char *keydbpath, * compatible with the NSS libraries (they seem to use the C runtime * library malloc/free so these functions are quite simple right now). */ +#if 0 /* we do not use ldapssl_malloc() yet */ static void * ldapssl_malloc( size_t size ) { @@ -242,8 +243,10 @@ ldapssl_malloc( size_t size ) p = malloc( size ); return p; } +#endif /* 0 */ +#if 0 /* we do not use ldapssl_calloc() yet */ static void * ldapssl_calloc( int nelem, size_t elsize ) { @@ -252,6 +255,7 @@ ldapssl_calloc( int nelem, size_t elsize ) p = calloc( nelem, elsize ); return p; } +#endif /* 0 */ static char * @@ -278,100 +282,6 @@ ldapssl_free( void **pp ) } -static char * -buildDBName(const char *basename, const char *dbname) -{ - char *result; - PRUint32 len, pathlen, addslash; - - if (basename) - { - if (( len = PL_strlen( basename )) > 3 - && PL_strcasecmp( ".db", basename + len - 3 ) == 0 ) { - return (ldapssl_strdup(basename)); - } - - pathlen = len; - len = pathlen + PL_strlen(dbname) + 1; - addslash = ( pathlen > 0 && - (( *(basename + pathlen - 1) != FILE_PATHSEP ) || - ( *(basename + pathlen - 1) != '\\' ))); - - if ( addslash ) { - ++len; - } - if (( result = ldapssl_malloc( len )) != NULL ) { - PL_strcpy( result, basename ); - if ( addslash ) { - *(result+pathlen) = FILE_PATHSEP; /* replaces '\0' */ - ++pathlen; - } - PL_strcpy(result+pathlen, dbname); - } - - } - - - return result; -} - -char * -GetCertDBName(void *alias, int dbVersion) -{ - char *source; - char dbname[128]; - - source = (char *)alias; - - if (!source) - { - source = ""; - } - - sprintf(dbname, "cert%d.db",dbVersion); - return(buildDBName(source, dbname)); - - -} - -/* - * return database name by appending "dbname" to "path". - * this code doesn't need to be terribly efficient (not called often). - */ -/* XXXceb this is the old function. To be removed eventually */ -static char * -GetDBName(const char *dbname, const char *path) -{ - char *result; - PRUint32 len, pathlen; - int addslash; - - if ( dbname == NULL ) { - dbname = ""; - } - - if ((path == NULL) || (*path == 0)) { - result = ldapssl_strdup(dbname); - } else { - pathlen = PL_strlen(path); - len = pathlen + PL_strlen(dbname) + 1; - addslash = ( path[pathlen - 1] != '/' ); - if ( addslash ) { - ++len; - } - if (( result = ldapssl_malloc( len )) != NULL ) { - PL_strcpy( result, path ); - if ( addslash ) { - *(result+pathlen) = '/'; /* replaces '\0' */ - ++pathlen; - } - PL_strcpy(result+pathlen, dbname); - } - } - - return result; -} - /* * Initialize ns/security so it can be used for SSL client authentication. * It is safe to call this more than once. diff --git a/mozilla/directory/c-sdk/ldap/libraries/libssldap/ldapsinit.c b/mozilla/directory/c-sdk/ldap/libraries/libssldap/ldapsinit.c index a7fe61a3b44..857fcfcb0d7 100644 --- a/mozilla/directory/c-sdk/ldap/libraries/libssldap/ldapsinit.c +++ b/mozilla/directory/c-sdk/ldap/libraries/libssldap/ldapsinit.c @@ -654,7 +654,7 @@ ldapssl_get_option( LDAP *ld, int option, int *onp ) ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); rc = -1; } else { - int rv, set_rv = 0; + int rv = 0, set_rv = 0; if ( NULL == ld ) { /* return default options for new LDAP sessions */