2007-08-21 [wwp] 2.10.0cvs145
authorTristan Chabredier <wwp@claws-mail.org>
Tue, 21 Aug 2007 21:43:23 +0000 (21:43 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Tue, 21 Aug 2007 21:43:23 +0000 (21:43 +0000)
* src/browseldap.c
* src/editldap.c
* src/ldapctrl.c
* src/ldapquery.c
* src/ldapserver.c
* src/ldapupdate.c
* src/ldaputil.c
More sanity checks in ldap functions.

ChangeLog
PATCHSETS
configure.ac
src/browseldap.c
src/editldap.c
src/ldapctrl.c
src/ldapquery.c
src/ldapserver.c
src/ldapupdate.c
src/ldaputil.c

index 21eb17ba2b3fad06ce528a518eaf786d45c9b3fa..1190f9351c37495c47afc650a0e9e19f73927e37 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-08-21 [wwp]       2.10.0cvs145
+
+       * src/browseldap.c
+       * src/editldap.c
+       * src/ldapctrl.c
+       * src/ldapquery.c
+       * src/ldapserver.c
+       * src/ldapupdate.c
+       * src/ldaputil.c
+               More sanity checks in ldap functions.
+
 2007-08-21 [wwp]       2.10.0cvs144
 
        * src/prefs_account.c
 2007-08-21 [wwp]       2.10.0cvs144
 
        * src/prefs_account.c
index e095d6317c6e8cf1203fcd909e537c3515180f18..fa0c8545ee951d700faf9f7e8cb881cd4c8b3a0c 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.8.2.25 -r 1.8.2.26 src/editldap.c;  cvs diff -u -r 1.2.2.13 -r 1.2.2.14 src/ldapctrl.c;  cvs diff -u -r 1.1.4.12 -r 1.1.4.13 src/ldapctrl.h;  cvs diff -u -r 1.3.2.21 -r 1.3.2.22 src/ldapquery.c;  cvs diff -u -r 1.1.2.12 -r 1.1.2.13 src/ldapupdate.c;  ) > 2.10.0cvs142.patchset
 ( cvs diff -u -r 1.94.2.146 -r 1.94.2.147 src/messageview.c;  ) > 2.10.0cvs143.patchset
 ( cvs diff -u -r 1.105.2.108 -r 1.105.2.109 src/prefs_account.c;  ) > 2.10.0cvs144.patchset
 ( cvs diff -u -r 1.8.2.25 -r 1.8.2.26 src/editldap.c;  cvs diff -u -r 1.2.2.13 -r 1.2.2.14 src/ldapctrl.c;  cvs diff -u -r 1.1.4.12 -r 1.1.4.13 src/ldapctrl.h;  cvs diff -u -r 1.3.2.21 -r 1.3.2.22 src/ldapquery.c;  cvs diff -u -r 1.1.2.12 -r 1.1.2.13 src/ldapupdate.c;  ) > 2.10.0cvs142.patchset
 ( cvs diff -u -r 1.94.2.146 -r 1.94.2.147 src/messageview.c;  ) > 2.10.0cvs143.patchset
 ( cvs diff -u -r 1.105.2.108 -r 1.105.2.109 src/prefs_account.c;  ) > 2.10.0cvs144.patchset
+( cvs diff -u -r 1.2.4.19 -r 1.2.4.20 src/browseldap.c;  cvs diff -u -r 1.8.2.26 -r 1.8.2.27 src/editldap.c;  cvs diff -u -r 1.2.2.14 -r 1.2.2.15 src/ldapctrl.c;  cvs diff -u -r 1.3.2.22 -r 1.3.2.23 src/ldapquery.c;  cvs diff -u -r 1.4.2.13 -r 1.4.2.14 src/ldapserver.c;  cvs diff -u -r 1.1.2.13 -r 1.1.2.14 src/ldapupdate.c;  cvs diff -u -r 1.1.4.9 -r 1.1.4.10 src/ldaputil.c;  ) > 2.10.0cvs145.patchset
index 09dcb17a8585d86966cc18ab33c7b5da815e42a5..678d3f793e862a229bd9cc5a778ed814e16f94c0 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=10
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=144
+EXTRA_VERSION=145
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index d4ee0c569625437c11c1dba5d44928f313274021..1b9cc936fd76a23b5bf3ed3352b9269033f3859a 100644 (file)
@@ -120,7 +120,9 @@ static gint browse_callback_entry(
        node = listValues;
        while( node ) {
                nvp = ( NameValuePair * ) node->data;
        node = listValues;
        while( node ) {
                nvp = ( NameValuePair * ) node->data;
-               debug_print("adding to list: %s->%s\n", nvp->name, nvp->value);
+               debug_print("adding to list: %s->%s\n",
+                               nvp->name?nvp->name:"null",
+                               nvp->value?nvp->value:"null");
                _displayQueue_ = g_list_append( _displayQueue_, nvp );
                node->data = NULL;
                node = g_list_next( node );
                _displayQueue_ = g_list_append( _displayQueue_, nvp );
                node->data = NULL;
                node = g_list_next( node );
@@ -324,7 +326,9 @@ static gboolean browse_idle( gpointer data ) {
                        nvp = ( NameValuePair * ) node->data;
                        text[COL_NAME]  = nvp->name;
                        text[COL_VALUE] = nvp->value;
                        nvp = ( NameValuePair * ) node->data;
                        text[COL_NAME]  = nvp->name;
                        text[COL_VALUE] = nvp->value;
-                       debug_print("Adding row to list: %s->%s\n", nvp->name, nvp->value);
+                       debug_print("Adding row to list: %s->%s\n",
+                                               nvp->name?nvp->name:"null",
+                                               nvp->value?nvp->value:"null");
                        gtk_clist_append(
                                GTK_CLIST(browseldap_dlg.list_entry), text );
 
                        gtk_clist_append(
                                GTK_CLIST(browseldap_dlg.list_entry), text );
 
index 6aa5af20d2576d8885374f6efed2bf152c31f29d..0d8c91f0cb166be147b453f6aea383bed7be46da 100644 (file)
@@ -97,6 +97,8 @@ static gboolean editldap_validate_criteria( gchar *criteria ) {
        gint i;
        gboolean errorFlag;
 
        gint i;
        gboolean errorFlag;
 
+       g_return_val_if_fail(criteria != NULL, TRUE);
+
        errorFlag = TRUE;
 
        /* Replace delimiters with spaces */
        errorFlag = TRUE;
 
        /* Replace delimiters with spaces */
@@ -1044,7 +1046,8 @@ AdapterDSource *addressbook_edit_ldap(
        tls = gtk_toggle_button_get_active(
                        GTK_TOGGLE_BUTTON( ldapedit.enable_tls ) );
 #endif
        tls = gtk_toggle_button_get_active(
                        GTK_TOGGLE_BUTTON( ldapedit.enable_tls ) );
 #endif
-       debug_print("saving server config:\nname: %s\nhost: %s\nbase: %s\ncriteria: %s\nbind: %s\nport: %d\ntime: %d\nmax_entries: %d\ntimeout: %d\ndynamic: %d\ncheck_match: %d\n",sName, sHost, sBase, sCrit, sBind, iPort, iTime, iMaxE, iAge, bSrch, bMatch);
+       debug_print("saving server config:\nname: %s\nhost: %s\nbase: %s\ncriteria: %s\nbind: %s\nport: %d\ntime: %d\nmax_entries: %d\ntimeout: %d\ndynamic: %d\ncheck_match: %d\n",
+                       sName, sHost, sBase, sCrit, sBind, iPort, iTime, iMaxE, iAge, bSrch, bMatch);
        fin = FALSE;
        if( *sName == '\0' ) fin = TRUE;
        if( *sHost == '\0' ) fin = TRUE;
        fin = FALSE;
        if( *sName == '\0' ) fin = TRUE;
        if( *sHost == '\0' ) fin = TRUE;
index 9207d3d583798f46ab778c39e4a9a335f6a1f5b7..aedd7d3ee2e106e5149926142dff778352f4f0db 100644 (file)
@@ -77,6 +77,10 @@ LdapControl *ldapctl_create( void ) {
  */
 void ldapctl_set_host( LdapControl* ctl, const gchar *value ) {
        ctl->hostName = mgu_replace_string( ctl->hostName, value );
  */
 void ldapctl_set_host( LdapControl* ctl, const gchar *value ) {
        ctl->hostName = mgu_replace_string( ctl->hostName, value );
+
+       if ( ctl->hostName == NULL )
+               return;
+
        g_strstrip( ctl->hostName );
        debug_print("setting hostname: %s\n", ctl->hostName);
 }
        g_strstrip( ctl->hostName );
        debug_print("setting hostname: %s\n", ctl->hostName);
 }
@@ -103,6 +107,10 @@ void ldapctl_set_port( LdapControl* ctl, const gint value ) {
  */
 void ldapctl_set_base_dn( LdapControl* ctl, const gchar *value ) {
        ctl->baseDN = mgu_replace_string( ctl->baseDN, value );
  */
 void ldapctl_set_base_dn( LdapControl* ctl, const gchar *value ) {
        ctl->baseDN = mgu_replace_string( ctl->baseDN, value );
+
+       if ( ctl->baseDN == NULL )
+               return;
+
        g_strstrip( ctl->baseDN );
        debug_print("setting baseDN: %s\n", ctl->baseDN);
 }
        g_strstrip( ctl->baseDN );
        debug_print("setting baseDN: %s\n", ctl->baseDN);
 }
@@ -114,6 +122,10 @@ void ldapctl_set_base_dn( LdapControl* ctl, const gchar *value ) {
  */
 void ldapctl_set_bind_dn( LdapControl* ctl, const gchar *value ) {
        ctl->bindDN = mgu_replace_string( ctl->bindDN, value );
  */
 void ldapctl_set_bind_dn( LdapControl* ctl, const gchar *value ) {
        ctl->bindDN = mgu_replace_string( ctl->bindDN, value );
+
+       if ( ctl->bindDN == NULL )
+               return;
+
        g_strstrip( ctl->bindDN );
        debug_print("setting bindDN: %s\n", ctl->bindDN);
 }
        g_strstrip( ctl->bindDN );
        debug_print("setting bindDN: %s\n", ctl->bindDN);
 }
@@ -125,6 +137,10 @@ void ldapctl_set_bind_dn( LdapControl* ctl, const gchar *value ) {
  */
 void ldapctl_set_bind_password( LdapControl* ctl, const gchar *value ) {
        ctl->bindPass = mgu_replace_string( ctl->bindPass, value );
  */
 void ldapctl_set_bind_password( LdapControl* ctl, const gchar *value ) {
        ctl->bindPass = mgu_replace_string( ctl->bindPass, value );
+
+       if ( ctl->bindPass == NULL )
+               return;
+
        g_strstrip( ctl->bindPass );
        debug_print("setting bindPassword");
 }
        g_strstrip( ctl->bindPass );
        debug_print("setting bindPassword");
 }
@@ -326,16 +342,16 @@ void ldapctl_print( const LdapControl *ctl, FILE *stream ) {
 
        pthread_mutex_lock( ctl->mutexCtl );
        fprintf( stream, "LdapControl:\n" );
 
        pthread_mutex_lock( ctl->mutexCtl );
        fprintf( stream, "LdapControl:\n" );
-       fprintf( stream, "host name: '%s'\n", ctl->hostName );
+       fprintf( stream, "host name: '%s'\n", ctl->hostName?ctl->hostName:"null" );
        fprintf( stream, "     port: %d\n",   ctl->port );
        fprintf( stream, "     port: %d\n",   ctl->port );
-       fprintf( stream, "  base dn: '%s'\n", ctl->baseDN );
-       fprintf( stream, "  bind dn: '%s'\n", ctl->bindDN );
-       fprintf( stream, "bind pass: '%s'\n", ctl->bindPass );
-       fprintf( stream, "attr mail: '%s'\n", ctl->attribEMail );
-       fprintf( stream, "attr comn: '%s'\n", ctl->attribCName );
-       fprintf( stream, "attr frst: '%s'\n", ctl->attribFName );
-       fprintf( stream, "attr last: '%s'\n", ctl->attribLName );
-       fprintf( stream, "attr disn: '%s'\n", ctl->attribDName );
+       fprintf( stream, "  base dn: '%s'\n", ctl->baseDN?ctl->baseDN:"null" );
+       fprintf( stream, "  bind dn: '%s'\n", ctl->bindDN?ctl->bindDN:"null" );
+       fprintf( stream, "bind pass: '%s'\n", ctl->bindPass?ctl->bindPass:"null" );
+       fprintf( stream, "attr mail: '%s'\n", ctl->attribEMail?ctl->attribEMail:"null" );
+       fprintf( stream, "attr comn: '%s'\n", ctl->attribCName?ctl->attribCName:"null" );
+       fprintf( stream, "attr frst: '%s'\n", ctl->attribFName?ctl->attribFName:"null" );
+       fprintf( stream, "attr last: '%s'\n", ctl->attribLName?ctl->attribLName:"null" );
+       fprintf( stream, "attr disn: '%s'\n", ctl->attribDName?ctl->attribDName:"null" );
        fprintf( stream, "max entry: %d\n",   ctl->maxEntries );
        fprintf( stream, "  timeout: %d\n",   ctl->timeOut );
        fprintf( stream, "  max age: %d\n",   ctl->maxQueryAge );
        fprintf( stream, "max entry: %d\n",   ctl->maxEntries );
        fprintf( stream, "  timeout: %d\n",   ctl->timeOut );
        fprintf( stream, "  max age: %d\n",   ctl->maxQueryAge );
@@ -479,7 +495,7 @@ static gchar *ldapctl_build_ldap_criteria(
                g_free( p2 );
        }
        g_free( term );
                g_free( p2 );
        }
        g_free( term );
-       debug_print("search criteria: %s\n", crit);
+       debug_print("search criteria: %s\n", crit?crit:"null");
        return crit;
 }
 
        return crit;
 }
 
index d6ce17acaf4b759fc5115274d26e1c55adcf2127..dd1d4720344ea4934bbcd6ffc64fd3dedb960877 100644 (file)
@@ -114,8 +114,11 @@ void ldapqry_set_control( LdapQuery *qry, LdapControl *ctl ) {
  * \param value Name.
  */
 void ldapqry_set_name( LdapQuery* qry, const gchar *value ) {
  * \param value Name.
  */
 void ldapqry_set_name( LdapQuery* qry, const gchar *value ) {
+       g_return_if_fail( qry != NULL );
+       g_return_if_fail( ADDRQUERY_NAME(qry) != NULL );
        ADDRQUERY_NAME(qry) = mgu_replace_string( ADDRQUERY_NAME(qry), value );
        g_strstrip( ADDRQUERY_NAME(qry) );
        ADDRQUERY_NAME(qry) = mgu_replace_string( ADDRQUERY_NAME(qry), value );
        g_strstrip( ADDRQUERY_NAME(qry) );
+       debug_print("set name: %s\n", ADDRQUERY_NAME(qry));
 }
 
 /**
 }
 
 /**
@@ -124,6 +127,8 @@ void ldapqry_set_name( LdapQuery* qry, const gchar *value ) {
  * \param value 
  */
 void ldapqry_set_search_value( LdapQuery *qry, const gchar *value ) {
  * \param value 
  */
 void ldapqry_set_search_value( LdapQuery *qry, const gchar *value ) {
+       g_return_if_fail( qry != NULL );
+       g_return_if_fail( ADDRQUERY_SEARCHVALUE(qry) != NULL );
        ADDRQUERY_SEARCHVALUE(qry) = mgu_replace_string( ADDRQUERY_SEARCHVALUE(qry), value );
        g_strstrip( ADDRQUERY_SEARCHVALUE(qry) );
        debug_print("search value: %s\n", ADDRQUERY_SEARCHVALUE(qry));
        ADDRQUERY_SEARCHVALUE(qry) = mgu_replace_string( ADDRQUERY_SEARCHVALUE(qry), value );
        g_strstrip( ADDRQUERY_SEARCHVALUE(qry) );
        debug_print("search value: %s\n", ADDRQUERY_SEARCHVALUE(qry));
@@ -152,6 +157,7 @@ void ldapqry_set_query_type( LdapQuery* qry, const gint value ) {
  */
 void ldapqry_set_search_type( LdapQuery *qry, const AddrSearchType value ) {
        g_return_if_fail( qry != NULL );
  */
 void ldapqry_set_search_type( LdapQuery *qry, const AddrSearchType value ) {
        g_return_if_fail( qry != NULL );
+       g_return_if_fail( ADDRQUERY_SEARCHTYPE(qry) != NULL );
        ADDRQUERY_SEARCHTYPE(qry) = value;
 }
 
        ADDRQUERY_SEARCHTYPE(qry) = value;
 }
 
@@ -161,6 +167,8 @@ void ldapqry_set_search_type( LdapQuery *qry, const AddrSearchType value ) {
  * \param value ID for the query.
  */
 void ldapqry_set_query_id( LdapQuery* qry, const gint value ) {
  * \param value ID for the query.
  */
 void ldapqry_set_query_id( LdapQuery* qry, const gint value ) {
+       g_return_if_fail( qry != NULL );
+       g_return_if_fail( ADDRQUERY_ID(qry) != NULL );
        ADDRQUERY_ID(qry) = value;
 }
 
        ADDRQUERY_ID(qry) = value;
 }
 
@@ -384,7 +392,8 @@ static GSList *ldapqry_add_list_values(
 
        if( ( vals = ldap_get_values_len( ld, entry, attr ) ) != NULL ) {
                for( i = 0; vals[i] != NULL; i++ ) {
 
        if( ( vals = ldap_get_values_len( ld, entry, attr ) ) != NULL ) {
                for( i = 0; vals[i] != NULL; i++ ) {
-                       /*debug_print("lv\t%s: %s\n", attr, vals[i]->bv_val);*/
+                       /*debug_print("lv\t%s: %s\n", attr?attr:"null",
+                                       vals[i]->bv_val?vals[i]->bv_val:"null");*/
                        list = g_slist_append( list, g_strndup( vals[i]->bv_val, vals[i]->bv_len) );
                }
        }
                        list = g_slist_append( list, g_strndup( vals[i]->bv_val, vals[i]->bv_len) );
                }
        }
@@ -405,7 +414,8 @@ static GSList *ldapqry_add_single_value( LDAP *ld, LDAPMessage *entry, char *att
 
        if( ( vals = ldap_get_values_len( ld, entry, attr ) ) != NULL ) {
                if( vals[0] != NULL ) {
 
        if( ( vals = ldap_get_values_len( ld, entry, attr ) ) != NULL ) {
                if( vals[0] != NULL ) {
-                       debug_print("sv\t%s: %s\n", attr, vals[0]->bv_val);
+                       debug_print("sv\t%s: %s\n", attr?attr:"null",
+                                       vals[0]->bv_val?vals[0]->bv_val:"null");
                        list = g_slist_append( list, g_strndup( vals[0]->bv_val, vals[0]->bv_len ));
                }
        }
                        list = g_slist_append( list, g_strndup( vals[0]->bv_val, vals[0]->bv_len ));
                }
        }
@@ -556,7 +566,7 @@ static GList *ldapqry_process_single_entry(
        listReturn = NULL;
        ctl = qry->control;
        dnEntry = ldap_get_dn( ld, e );
        listReturn = NULL;
        ctl = qry->control;
        dnEntry = ldap_get_dn( ld, e );
-       debug_print( "DN: %s\n", dnEntry );
+       debug_print( "DN: %s\n", dnEntry?dnEntry:"null" );
 
        /* Process all attributes */
        for( attribute = ldap_first_attribute( ld, e, &ber ); attribute != NULL;
 
        /* Process all attributes */
        for( attribute = ldap_first_attribute( ld, e, &ber ); attribute != NULL;
@@ -684,7 +694,8 @@ static gint ldapqry_connect( LdapQuery *qry ) {
        }
        ldapqry_touch( qry );
 
        }
        ldapqry_touch( qry );
 
-       debug_print("connected to LDAP host %s on port %d\n", ctl->hostName, ctl->port);
+       debug_print("connected to LDAP host %s on port %d\n",
+                       ctl->hostName?ctl->hostName:"null", ctl->port);
 
 #ifdef USE_LDAP_TLS
        /* Handle TLS */
 
 #ifdef USE_LDAP_TLS
        /* Handle TLS */
@@ -700,8 +711,8 @@ static gint ldapqry_connect( LdapQuery *qry ) {
                        rc = ldap_start_tls_s( ld, NULL, NULL );
                        
                        debug_print("rc=%d\n", rc);
                        rc = ldap_start_tls_s( ld, NULL, NULL );
                        
                        debug_print("rc=%d\n", rc);
-                       debug_print("LDAP Status: set_option: %s\n", ldap_err2string( rc ) );
-                       
+                       debug_print("LDAP Status: set_option: %s\n", ldap_err2string(rc));
+
                        if( rc != LDAP_SUCCESS ) {
                                return ADDRQUERY_RETVAL(qry);
                        }
                        if( rc != LDAP_SUCCESS ) {
                                return ADDRQUERY_RETVAL(qry);
                        }
@@ -787,7 +798,7 @@ static gint ldapqry_search_retrieve( LdapQuery *qry ) {
 
        /* Create LDAP search string */
        criteria = ldapctl_format_criteria( ctl, ADDRQUERY_SEARCHVALUE(qry) );
 
        /* Create LDAP search string */
        criteria = ldapctl_format_criteria( ctl, ADDRQUERY_SEARCHVALUE(qry) );
-       debug_print("Search criteria ::%s::\n", criteria);
+       debug_print("Search criteria ::%s::\n", criteria?criteria:"null");
 
        /*
         * Execute the search - this step may take some time to complete
 
        /*
         * Execute the search - this step may take some time to complete
@@ -1001,7 +1012,11 @@ static void ldapqry_destroyer( void * ptr ) {
        LdapQuery *qry;
 
        qry = ( LdapQuery * ) ptr;
        LdapQuery *qry;
 
        qry = ( LdapQuery * ) ptr;
-       debug_print("ldapqry_destroyer::%d::%s\n", (int) pthread_self(), ADDRQUERY_NAME(qry));
+       g_return_if_fail( qry != NULL );
+       g_return_if_fail( ADDRQUERY_NAME(qry) != NULL );
+
+       debug_print("ldapqry_destroyer::%d::%s\n", (int) pthread_self(),
+                       ADDRQUERY_NAME(qry));
 
        /* Perform any destruction here */
        if( qry->control != NULL ) {
 
        /* Perform any destruction here */
        if( qry->control != NULL ) {
@@ -1331,6 +1346,8 @@ gboolean ldapquery_remove_results( LdapQuery *qry ) {
 }
 
 void ldapqry_print(LdapQuery *qry, FILE *stream) {
 }
 
 void ldapqry_print(LdapQuery *qry, FILE *stream) {
+       g_return_if_fail( qry != NULL );
+
        ldapsvr_print_data(qry->server, stream);
        ldapctl_print(qry->control, stream);
        fprintf(stream, "entriesRead: %d\n", qry->entriesRead);
        ldapsvr_print_data(qry->server, stream);
        ldapctl_print(qry->control, stream);
        fprintf(stream, "entriesRead: %d\n", qry->entriesRead);
@@ -1341,7 +1358,7 @@ void ldapqry_print(LdapQuery *qry, FILE *stream) {
        fprintf(stream, "completed: %d\n", qry->completed);
        fprintf(stream, "startTime: %d\n", (int) qry->startTime);
        fprintf(stream, "touchTime: %d\n", (int) qry->touchTime);
        fprintf(stream, "completed: %d\n", qry->completed);
        fprintf(stream, "startTime: %d\n", (int) qry->startTime);
        fprintf(stream, "touchTime: %d\n", (int) qry->touchTime);
-       fprintf(stream, "data: %s\n", (gchar *) qry->data);
+       fprintf(stream, "data: %s\n", qry->data?(gchar *)qry->data:"null");
 }
 
 #endif /* USE_LDAP */
 }
 
 #endif /* USE_LDAP */
index 75c73c0406d5e083fd19c6d332912f272285e5a9..7fc9d7a99aac90317602372a9d397c604385f60f 100644 (file)
@@ -90,7 +90,7 @@ gchar *ldapsvr_get_name( LdapServer *server ) {
 void ldapsvr_set_name( LdapServer* server, const gchar *value ) {
        g_return_if_fail( server != NULL );
        addrcache_set_name( server->addressCache, value );
 void ldapsvr_set_name( LdapServer* server, const gchar *value ) {
        g_return_if_fail( server != NULL );
        addrcache_set_name( server->addressCache, value );
-       debug_print("setting name: %s\n", value);
+       debug_print("setting name: %s\n", value?value:"null");
 }
 
 /**
 }
 
 /**
@@ -98,6 +98,7 @@ void ldapsvr_set_name( LdapServer* server, const gchar *value ) {
  * \param server Server object.
  */
 void ldapsvr_force_refresh( LdapServer *server ) {
  * \param server Server object.
  */
 void ldapsvr_force_refresh( LdapServer *server ) {
+       g_return_if_fail( server != NULL );
        addrcache_refresh( server->addressCache );
 }
 
        addrcache_refresh( server->addressCache );
 }
 
@@ -491,7 +492,8 @@ void ldapsvr_retire_query( LdapServer *server ) {
                ldapqry_age( qry, maxAge );
                if( qry->agedFlag ) {
                        /* Delete folder associated with query */
                ldapqry_age( qry, maxAge );
                if( qry->agedFlag ) {
                        /* Delete folder associated with query */
-                       debug_print("deleting folder... ::%s::\n", ADDRQUERY_NAME(qry));
+                       debug_print("deleting folder... ::%s::\n",
+                                       ADDRQUERY_NAME(qry)?ADDRQUERY_NAME(qry):"null");
                        ldapqry_delete_folder( qry );
                        listDelete = g_list_append( listDelete, qry );
                }
                        ldapqry_delete_folder( qry );
                        listDelete = g_list_append( listDelete, qry );
                }
@@ -698,9 +700,12 @@ LdapQuery *ldapsvr_new_explicit_search(
 
 gint ldapsvr_read_data( LdapServer *server )
 {
 
 gint ldapsvr_read_data( LdapServer *server )
 {
+       gchar *name;
+
        g_return_val_if_fail( server != NULL, -1 );
 
        g_return_val_if_fail( server != NULL, -1 );
 
-       debug_print("...addrbook_read_data :%s:\n", addrcache_get_name(server->addressCache));
+       name = addrcache_get_name(server->addressCache);
+       debug_print("...addrbook_read_data :%s:\n", name?name:"null");
        
        addrcache_clear(server->addressCache);
        ldapsvr_free_all_query( server );
        
        addrcache_clear(server->addressCache);
        ldapsvr_free_all_query( server );
index d8425c67c357ab7cea127572e5d6dcc8b0b5e99c..251bd2a9579022350ee45ddcd49646fb7c051625 100644 (file)
@@ -232,15 +232,15 @@ void ldapsvr_print_contacts_hashtable(gpointer key, gpointer data, gpointer fd)
                while (node) {
                        EmailKeyValue *item = node->data;
                        if (debug_get_mode()) {
                while (node) {
                        EmailKeyValue *item = node->data;
                        if (debug_get_mode()) {
-                               debug_print("\t\talias = %s\n", item->alias);
-                               debug_print("\t\tmail = %s\n", item->mail);
-                               debug_print("\t\tremarks = %s\n", item->remarks);
+                               debug_print("\t\talias = %s\n", item->alias?item->alias:"null");
+                               debug_print("\t\tmail = %s\n", item->mail?item->mail:"null");
+                               debug_print("\t\tremarks = %s\n", item->remarks?item->remarks:"null");
                        }
                        else if (fd) {
                                FILE *stream = (FILE *) fd;
                        }
                        else if (fd) {
                                FILE *stream = (FILE *) fd;
-                               fprintf(stream, "\t\talias = %s\n", item->alias);
-                               fprintf(stream, "\t\tmail = %s\n", item->mail);
-                               fprintf(stream, "\t\tremarks = %s\n", item->remarks);
+                               fprintf(stream, "\t\talias = %s\n", item->alias?item->alias:"null");
+                               fprintf(stream, "\t\tmail = %s\n", item->mail?item->mail:"null");
+                               fprintf(stream, "\t\tremarks = %s\n", item->remarks?item->remarks:"null");
                        }
                        node = g_list_next(node);
                }
                        }
                        node = g_list_next(node);
                }
@@ -250,21 +250,23 @@ void ldapsvr_print_contacts_hashtable(gpointer key, gpointer data, gpointer fd)
                while (node) {
                        AttrKeyValue *item = node->data;
                        if (debug_get_mode()) {
                while (node) {
                        AttrKeyValue *item = node->data;
                        if (debug_get_mode()) {
-                               debug_print("\t\t%s = %s\n", item->key, item->value);
+                               debug_print("\t\t%s = %s\n", item->key?item->key:"null",
+                                               item->value?item->value:"null");
                        }
                        else if (fd) {
                                FILE *stream = (FILE *) fd;
                        }
                        else if (fd) {
                                FILE *stream = (FILE *) fd;
-                               fprintf(stream, "\t\t%s = %s\n", item->key, item->value);
+                               fprintf(stream, "\t\t%s = %s\n", item->key?item->key:"null",
+                                               item->value?item->value:"null");
                        }
                        node = g_list_next(node);
                }
        }
        else {
                if (debug_get_mode())
                        }
                        node = g_list_next(node);
                }
        }
        else {
                if (debug_get_mode())
-                       debug_print("\t\t%s = %s\n", keyName, (gchar *) data);
+                       debug_print("\t\t%s = %s\n", keyName?keyName:"null", data?(gchar *)data:"null");
                else if (fd) {
                        FILE *stream = (FILE *) fd;
                else if (fd) {
                        FILE *stream = (FILE *) fd;
-                       fprintf(stream, "\t\t%s = %s\n", keyName, (gchar *) data);
+                       fprintf(stream, "\t\t%s = %s\n", keyName?keyName:"null", data?(gchar *)data:"null");
                }
        }
 }
                }
        }
 }
@@ -887,7 +889,8 @@ void ldapsvr_handle_other_attributes(LDAP *ld, LdapServer *server, char *dn, GHa
                if (item) {
                        int index = get_attribute_index(item->key);
                        if (index >= 0) {
                if (item) {
                        int index = get_attribute_index(item->key);
                        if (index >= 0) {
-                               debug_print("Found other attribute: %s = %s\n", item->key, item->value);
+                               debug_print("Found other attribute: %s = %s\n",
+                                               item->key?item->key:"null", item->value?item->value:"null");
                                mod_op = ldapsvr_deside_operation(ld, server, dn, item->key, item->value);
                                /* Only consider attributes which we no how to handle.
                                 * Set to TRUE in CHECKED_ATTRIBUTE array to indicate no further action
                                mod_op = ldapsvr_deside_operation(ld, server, dn, item->key, item->value);
                                /* Only consider attributes which we no how to handle.
                                 * Set to TRUE in CHECKED_ATTRIBUTE array to indicate no further action
@@ -959,7 +962,7 @@ void ldapsvr_handle_other_attributes(LDAP *ld, LdapServer *server, char *dn, GHa
                                server->retVal = LDAPRC_ALREADY_EXIST;
                                break;
                        default:
                                server->retVal = LDAPRC_ALREADY_EXIST;
                                break;
                        default:
-                               g_printerr("ldap_modify for dn=%s\" failed[0x%x]: %s\n",dn, rc, ldap_err2string(rc));
+                               g_printerr("ldap_modify for dn=%s\" failed[0x%x]: %s\n", dn, rc, ldap_err2string(rc));
                                if (rc == 0x8)
                                        server->retVal = LDAPRC_STRONG_AUTH;
                                else
                                if (rc == 0x8)
                                        server->retVal = LDAPRC_STRONG_AUTH;
                                else
@@ -1018,7 +1021,8 @@ void ldapsvr_add_contact(LdapServer *server, GHashTable *contact) {
                clean_up(ld, server, contact);
                return;
        }
                clean_up(ld, server, contact);
                return;
        }
-       base_dn = g_strdup_printf("mail=%s,%s", email, server->control->baseDN);
+       base_dn = g_strdup_printf("mail=%s,%s",
+                       email, server->control->baseDN?server->control->baseDN:"null");
        g_free(email);
        person = 
                ldapsvr_get_contact(server, g_hash_table_lookup(contact , "uid"));
        g_free(email);
        person = 
                ldapsvr_get_contact(server, g_hash_table_lookup(contact , "uid"));
@@ -1096,7 +1100,8 @@ void ldapsvr_add_contact(LdapServer *server, GHashTable *contact) {
                                server->retVal = LDAPRC_ALREADY_EXIST;
                                break;
                        default:
                                server->retVal = LDAPRC_ALREADY_EXIST;
                                break;
                        default:
-                               g_printerr("ldap_modify for dn=%s\" failed[0x%x]: %s\n",base_dn, rc, ldap_err2string(rc));
+                               g_printerr("ldap_modify for dn=%s\" failed[0x%x]: %s\n",
+                                               base_dn, rc, ldap_err2string(rc));
                                if (rc == 0x8)
                                        server->retVal = LDAPRC_STRONG_AUTH;
                                else
                                if (rc == 0x8)
                                        server->retVal = LDAPRC_STRONG_AUTH;
                                else
index 0c0a273adf489a56e5a69c06c8d7c0340e36e0f2..e29947816070e336a1488b24a529490dbb024e87 100644 (file)
@@ -205,7 +205,7 @@ int claws_ldap_simple_bind_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *pa
                cred.bv_len = 0;
        }
 
                cred.bv_len = 0;
        }
 
-       debug_print("binding: DN->%s\n", dn);
+       debug_print("binding: DN->%s\n", dn?dn:"null");
        return ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &cred,
                NULL, NULL, NULL );
 }
        return ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &cred,
                NULL, NULL, NULL );
 }